I want to use JavaScript (I can also use jQuery) to do check whether a string matches the regex ^([a-z0-9]{5,})$
, and get a true
or false
result.
match()
seems to check whether part of a string matches a regex, not the whole thing. Does it solve the problem? Can I adapt it to solve the problem? How?
match
doesn't require the entire string to match the regex. But the^
and$
anchors ensure that this regex can only possibly match against the entire string - that's their purpose.