Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: regular expressions: escape characters handled incorrectly


From   James Muller <james.muller@anu.edu.au>
To   statalist@hsphsun2.harvard.edu
Subject   st: regular expressions: escape characters handled incorrectly
Date   Wed, 14 Feb 2007 17:48:34 +1100

Hi y'all. Been a while.

Found a problem with Stata's regular expression parser. It doesn't
handle escapes (\'s) correctly. Was doing this while writing a regular
expression to verify a valid varlist in a very non-standard syntax
parser.

   di regexm("(id1-2)", "\([\-0-9]*\)")

The \-\0-9 in the [] should match numbers (0-9) and dash ("-"), but
reads the escaped dash as another range operator. The specific error
is

   regexp: invalid [] range

If anyone has a hack to obtain an equivalent regexp, or if Stata has
any comments, gratitude in advance.

Cheers

James
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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