From: Richard Kilmer Date: 2004-10-06T01:06:38+09:00 Subject: Re: Regexp match question on interpolated strings... I am working in an environment that is neither Ruby or Perl. The piece of code looks something like this: { name = "Double Quoted String"; begin = "\""; end = "\""; foregroundColor = "#66CC33"; patterns = ( { name = "Interpolated String"; match = "#\\{([^\\}]*)\\}"; foregroundColor = "#aaaaaa"; } ); }, This is a syntax highlighting system for an editor. As you can see, you can use either begin="regexp"; end="regexp" or match="regexp" and patterns can be nested. What I have works...assuming that the code inside the #{ ... } does not, itself contain braces (which is limiting, I know). -rich On 10/5/04 10:04 AM, "James Edward Gray II" wrote: > On Oct 5, 2004, at 4:09 AM, Brian Schr�der wrote: > >> Regular expressions are not able to "count" more than a finite number >> of states, and the number of states is fixed at compile time. That is >> because regular expressions map to finite automata. So it is >> impossible to match opening and closing braces in an unknown >> expression. For this to work always you need a model that can enter >> unbounded many states. > > Just for the sake of clarity, you are speaking of Ruby's regular > expressions here. Perl's regex engine has no such limitation. Using > the (?? ... ) construct, Perl regular expressions can parse balanced > delimiters. I miss this feature and would love to see Ruby add > something similar in the future. > > James Edward Gray II > > >