c# - Why does this Regex match? -


i have written regular expression match following criteria

  • any digit (0-9)
  • hyphen
  • whitespace
  • in order
  • length between 10 , 25

([0-9\-\w]{10,25})

i using detect payment card numbers, works:

regex.ismatch("34343434343434", "([0-9\\-\\w]{10,25})"); // true 

but works:

regex.ismatch("logmethodcomplete", "([0-9\\-\\w]{10,25})"); // true 

what doing wrong?

this c#

take @ regular expression language - quick reference, section character classes.

\w matches word character including underscore, not whitespace.

to match whitespace, can use \s.

to match digits, can use \d.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -