Regex to match only two specific words, e.g. Yes or No -
my attempt is:
^yes|^no|^$  but when use this, words other "yes" , "no" matched
how fix it?
i've been testing regex using this online regex tester.
try this:
^(?:yes|no)$ in vbscript, this:
dim myregexp, foundmatch set myregexp = new regexp myregexp.pattern = "^(?:yes|no)$" foundmatch = myregexp.test(subjectstring) what problem?
you had alternation 3 options:
- ^yesmatches- yes@ beginning of string, match- yesin- yes, man...
- ^nomatches- no@ beginning of string, match- noin- no way!
- ^$matches empty string
Comments
Post a Comment