[Mono-list] Re gular expression inconsistency between Mono 2.4 and .Net
holyfuzz
walt at waltdestler.com
Thu Apr 9 18:23:09 EDT 2009
I am having a problem where my regular expression is not properly matching a
string in Mono 2.4 but *is* properly matching the string in .Net.
Interestingly, this particular case worked fine in Mono 2.2, but not 2.0 or
2.4.
Here is my regular expression:
Regex re = new
Regex(@"^\s*&?\s*([a-zA-Z0-9_-_]+|/|\^|~|\.|\.\.|\<(.*)\>|#)?\s*(/\s*([a-zA-Z0-9_-_]+|\^|\.\.|#)\s*)*/?\s*$");
And the string I am trying to match is:
../../Col1
To determine whether the string matches, I use the following code:
Match m = re.Match(path);
if(m.Success){do stuff}
Since my regular expression is pretty complicated, I'll try to explain it in
English:
1) The string may optionally start with an ampersand: &
2) There is then a series of one or more forward-slash-separated
sequences...
3) Any sequence may be one of the following:
3a) A word containing letters, digits, or underscores.
3b) An up caret: ^
3c) Two dots: ..
3d) A pound symbol: #
4) The very first sequence may in addition be the following:
4a) A forward-slash: /
4b) A tilde: ~
4c) A single dot: .
4d) Any string of characters enclosed by <> brackets.
5) The string may optionally end with a forward-slash: /
Thus my RE should, in theory, match my string
../../Col1
but on Mono 2.0 and 2.4 it does not, while on 2.2 and .Net it works fine.
Is this a bug in Mono, or is there something wrong with my RE? In either
case, is there a way I can fix my RE so that it works?
Thanks!
--
View this message in context: http://www.nabble.com/Regular-expression-inconsistency-between-Mono-2.4-and-.Net-tp22980228p22980228.html
Sent from the Mono - General mailing list archive at Nabble.com.
More information about the Mono-list
mailing list