MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Bug with Regular Expression?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105784] Bug with Regular Expression?
  • From: dh <dh at metrohm.com>
  • Date: Fri, 18 Dec 2009 06:25:16 -0500 (EST)


Hello,

either I am missing something or the following is a bug.

According to the manual, mathematica string pattern matcher is built in 

top of the PCRE library. Therefore the following matches for nested 

parenthesis should be equivalent:



s1 = "\\(([^()]*|(?R))*\\)";

s2 = "(\\(([^()]*|(?1))*\\))";

StringMatchQ["(1(2)3)", RegularExpression[s1]]

StringMatchQ["(1(2)3)", RegularExpression[s2]]



Both use recursion. The first one uses the whole pattern: (?R). The 

second one uses the first capture, that happens to be the whole pattern.

Obviously, only the second possibility works.



Daniel




  • Prev by Date: Find maxima in lists of data
  • Next by Date: FindFit constrains when parameters are in table form?
  • Previous by thread: Re: Find maxima in lists of data
  • Next by thread: FindFit constrains when parameters are in table form?