Hi,
I've got a problem with RegEx in the 2.0 Beta. I have a regexp expression
that works fine in the 1.1 version of the framework but breaks in 2.0. I'm
no regexp guru, so I don't really know why version 2.0 returns incorrect
results.
I have this string:
value,Var,[L1,L2,[L3,L4]],'Text',[L1,L2,L3],pro(a,b,c)
And I use this regexp pattern:
(?<list>\[(?>([^[]|[]])+
|
\[ (?<DEPTH>)
|
\] (?<-DEPTH>)
)*
(?(DEPTH)(?!))\])
(?<structure>\w*\((?>
[^()]+
|
\( (?<DEPTH>)
|
\) (?<-DEPTH>)
)*
(?(DEPTH)(?!))\))
('(?<quot>[\w]*)')
(?<variable>[A-Z???]\w*)
(?<value>[a-z???]\w*)
...with the options RegexOptions.Compiled and
RegexOptions.IgnorePatternWhitespace.
These are the results. Only one capture group succeeds in each match.
Capture group - Captured value
In 1.1
value - value
variable - Var
list - [L1,L2,[L3,L4]]
quot - Text
list - [L1,L2,L3]
structure - pro(a,b,c)
In 2.0
value - value
variable - Var
variable - L1
variable - L2
variable - L3
variable - L4
quot - Text
variable - L1
variable - L2
variable - L3
structure - pro(a,b,c)
I hope that you can help with this. Sorry for cross posting, follow up to
microsoft.public.dotnet.framework.
/Hugo
WALDO - 03 Dec 2004 10:44 GMT
My fist guess is that you have to use the ExplicitCapture option as
well.
Sometimes the greatest solutions come from the simplest logic.
Being told "No" is merely the incentive to do it anyway.
Hugo Wetterberg - 03 Dec 2004 13:29 GMT
No, that's not it.
I've noticed another thing as well. The regex expression works fine as long
as the assembly is executed by the 1.1 runtime. It doesn't help if the
assembly references the 1.1 framework, executing it in the 2.0 runtime
breaks it anyway. I've worked around this problem by putting the regex-part
in a 1.1 web-service, and this works fine as a temporary solution. But it's
only for testing and not really a viable solution in a real-world
application.
/Hugo
> My fist guess is that you have to use the ExplicitCapture option as
> well.
[quoted text clipped - 4 lines]
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!