Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Technical Support
 Discarding brackets in C# regular expressions
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peck797
Tomato Guru

United Kingdom
171 Posts

Posted - Feb 17 2012 :  11:40:44 AM  Show Profile  Reply with Quote
Unfortunately, I can't reproduce this behaviour all the time but I have found one particular regex string where it seems to be reproducible and repeatable on my PC.

I have the following definition:

regex_ = new Regex(
@"^\\s*\\[\\s*"
+ @"(?<longHem>(?:N(?:orth)?)|(?:S(?:outh)?))\\s*\\.\\s*"
+ @"(?<longDeg>(?:\\+|\\-)?\\d+)\\s*\\.\\s*"
+ @"(?<longMin>\\d+)\\s*\\.\\s*"
+ @"(?<longSec>\\d+(?:.\\d*)?)\\s*,\\s*"
+ @"(?<latHem>(?:E(?:ast)?)|(?:W(?:est)?))\\s*\\.\\s*"
+ @"(?<latDeg>(?:\\+|\\-)?\\d+)\\s*\\.\\s*"
+ @"(?<latMin>\\d+)\\s*\\.\\s*"
+ @"(?<latSec>\\d+(?:.\\d*)?)\\s*"
+ @"(?:,\\s*(?<alt>(?:\\+|\\-)?\\d+(?:.\\d*)?))?\\s*"
+ @"\\]\\s*$",
RegexOptions.Compiled | RegexOptions.IgnoreCase);

If I put the caret before some of the ')' characters in part of that expression and hit the ')' key on my keyboard, then VAX "absorbs" the ')' and jumps over it. This is despite the fact that, IMO, it's a string and shouldn't be being parsed but it even happens if there is, in fact, a missing ')' somewhere in the expression (which is why I hit the problem in practice!)

For example, try putting the caret before the final ')' in the penultimate string part:

+ @"(?:,\\s*(?<alt>(?:\\+|\\-)?\\d+(?:.\\d*)?))?\\s*"

and hit the ')' key. For me, it jumps over that character rather than adding a new one. It will do this even if you delete one of the earlier '(' characters on the same line.

If you can't reproduce it, then I'll go back to sleep; it's not life threatening but I seem to have found one case where this occasional glitch is 100% repeatable for me!

Dan

feline
Whole Tomato Software

United Kingdom
19078 Posts

Posted - Feb 17 2012 :  7:46:45 PM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description. This looks like it is covered by:

case=3942

Hopefully you don't have to many cases where you run into this rather unhelpful problem.

zen is the art of being at one with the two'ness
Go to Top of Page

peck797
Tomato Guru

United Kingdom
171 Posts

Posted - Feb 18 2012 :  01:50:07 AM  Show Profile  Reply with Quote
It's good to know that you can reproduce it.

Dan

Water that is too pure has no fish; whether that be red fish or blue fish.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000