Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / December 2004

Tip: Looking for answers? Try searching our database.

Help - RegEx, differences between  FW 1.1 and 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Hugo Wetterberg - 02 Dec 2004 19:33 GMT
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!

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.