Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: regular expression functions in MATA


From   Federico Belotti <[email protected]>
To   StataList <[email protected]>
Subject   st: regular expression functions in MATA
Date   Thu, 07 Jan 2010 18:56:17 +0100

Dear all,

I've a question about mata. I'm working with the -regexm()- function in mata.

-regexm()- function seems to work fine with vectors. The same is not true for -regexs()-, because a loop is needed.
Is there a way to use -regexs()- function in mata with vectors?

The following is an example:

clear
input str18 date
20jan2007
16June06
06sept1985
21june04
4july90
9jan1999
6aug99
19august2003
end

*** -regexs()- function works perfectly with stata
gen day = regexs(0) if regexm(date, "^[0-9]+")
list day

tomata

capture mata: mata drop example()
mata

real matrix example(var)
{
/// -regexm()- function seems to work directly with vectors

one = regexm(var, "^[0-9]+")
one

two = J(8, 1, "")
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index