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

php - Hide output during test execution -

javascript - Migrate custom AngularJS filter from 1.2.28 to 1.4.x -

Update Magento products with multiple images -