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 wouldn't "ba" be in your string, why wouldn't "a" be in your string, and why wouldn't "" 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 didn't cross my mind, such an easy quick fix.

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