c# - Why is the regular expression trying to make submatch? -



c# - Why is the regular expression trying to make submatch? -

i newbie regex please bear me if trivial question. next this. want see if input has next pattern:

<any number of spaces><one or more of alphanumeric character>;<any number of possible spaces>

if input has above look homecoming matches.

the regular look have follows:

\s*\w+\s*?;\s*

when

regex.ismatch(input, pattern, regexoptions.ignorecase)

even if have valid input "a;" or " a;" end getting false.

when examine using regex tool, seems matches whole thing , tries find submatch sec \s* 1 time again @ point says no sub match. can explain why getting false?

the next work according needs.

\s*\w+;\s*

example:

console.writeline(regex.ismatch("a;", @"\s*\w+;\s*")); // true console.writeline(regex.ismatch(" a;", @"\s*\w+;\s*")); // true console.writeline(regex.ismatch("a; ", @"\s*\w+;\s*")); // true

c# regex

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -