I have a Regex pattern, which is all alphanumeric characters, and -
, _ < / Code>,
.
and location
"[A-Za-z0-9-_.] +"
I have a string with this code Trying to use Regex.IsMatch
, but it returns true
. Why?
string pattern = "[A-Za-z0-9-_.] +"; String input = "RTGF & amp; ** ((& amp;; bool is match = regesx.ismatch (input, pattern); // is true, why?
This matches because your string contains one or more characters in This pattern breaks from the beginning to the end of the string to match If you will. [A-Za-z0- 9-_.] If you want only to set, change your pattern to:
string pattern = "^ [azza-j 0-9] -D.] + $ ";
Comments
Post a Comment