T
Tom Jones
Hi,
I have a component that accepts a string representing a class of files
(exactly like those you would pass to the 'dir' dos command, ie. '*.txt', or
'???.cpp').
An exception is generated if I try to create a Regex like this:
Regex r = new Regex("*.txt");
I understand why that is a problem, thus I parse my filter strings as such:
'*' gets replaced by '.*', '?' gets replaced by '.{1}', and any '.' found in
the original filter is replaced with its hex representation, '\x2E'.
Thus something like "???.a" (any 3 letter filename that ends in an 'a') we
be sent to the Regex ctor as such:
Regex r = new Regex(@"^.{1}.{1}.{1}\x2Ea$");
My problem is that the result of r.IsMatch("0.0.1235.a") is *true*!!??
Can someone please explain why r.IsMatch() returns true in this case?
Thanks!
Tom
I have a component that accepts a string representing a class of files
(exactly like those you would pass to the 'dir' dos command, ie. '*.txt', or
'???.cpp').
An exception is generated if I try to create a Regex like this:
Regex r = new Regex("*.txt");
I understand why that is a problem, thus I parse my filter strings as such:
'*' gets replaced by '.*', '?' gets replaced by '.{1}', and any '.' found in
the original filter is replaced with its hex representation, '\x2E'.
Thus something like "???.a" (any 3 letter filename that ends in an 'a') we
be sent to the Regex ctor as such:
Regex r = new Regex(@"^.{1}.{1}.{1}\x2Ea$");
My problem is that the result of r.IsMatch("0.0.1235.a") is *true*!!??
Can someone please explain why r.IsMatch() returns true in this case?
Thanks!
Tom