Regex.IsMatch() true when input char is empty

Probably because there are (hypothetically) strings of zero length inside of your string there.
If "oba" is in your string, why wouldnt "ba" be in your string, why wouldnt "a" be in your string, and why wouldnt "" be in your string?
I would suggest doing something like this:
Code:
(Regex.IsMatch("foobar", txtInput.Text) && txtInput.Text.Length > 0)
 
Yea, it was pretty obvious to me that .Net sees "" as part of a value. I have no idea why .Text.Length > 0 didnt cross my mind, such an easy quick fix.

Is it me or does this seem like a real bizarre thing for RegEx because I dont recall Perl or PHP (ugh, PHP regex!) ever behaving like this.
 
Back
Top