Help - RegEx, differences between FW 1.1 and 2.0

  • Thread starter Hugo Wetterberg
  • Start date
H

Hugo Wetterberg

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
 
W

WALDO

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.
 
H

Hugo Wetterberg

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top