Hi
By accident I found out that regexm is a vector function in both arguments.
This makes regexm even more powerfull!!
Take a look:
If you (as I do) has to handle string data from time to time then you will probably agree that this is quite nice
By accident I found out that regexm is a vector function in both arguments.
This makes regexm even more powerfull!!
Take a look:
Code:
: txt = "We discuss Stata, statistics, and Stata and statistics. You can browse without registering but you need to register to participate in the discussion or ask a question." : tok = tokens(txt) // Text to string vector : select(tok, regexm(tok, "s$")) // Get words ending on "s" discuss : select(tok, regexm(tok, "s$|s\.$")) // Get words ending on "s" or "s." 1 2 +-----------------------------+ 1 | discuss statistics. | +-----------------------------+ : select(tok, regexm(tok, "q")) // Get words containing "q" question. : select(tok, regexm(tok, "[se]$")) // Words ending on either "s" or "e" 1 2 3 4 5 +-----------------------------------------------------------------------+ 1 | We discuss browse participate the | +-----------------------------------------------------------------------+ // Now the other way around: : regexm(txt, ("ss", "se", "so")) // Which of the strings "ss", "se" and "so" appear in txt? 1 2 3 +-------------+ 1 | 1 1 0 | +-------------+ : any(regexm(txt, ("ss", "se", "so"))) // Does any of the strings "ss", "se" and "so" appear in txt? 1 : all(regexm(txt, ("ss", "se", "so"))) // Do all of them? 0
Comment