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

python - jinja2: TemplateSyntaxError: expected token ',', got 'string' -

Qt4: how to send QString inside a struct via QSharedMemory -

node.js - NodeJS remote terminal to Dropbear OpenWRT-Server -