Having regex patter like this:
ab*d why does it return match true for input
abbbde ? How to change it to check also last character ?
Lets analyse your regex:
a - match an "a"
b* - match any number of b's
d - match a "d"
Because * matches any number of b's.
$ matches end of line, so
should match end of line (to make sure nothing follows)
Then again \s will match any whitespace so another option is
You need to add a
$ at the end of the pattern to ensure it is the last character
$ is called a
End of String Anchor in Regular Expressions. You can read more on Anchors here http://www.regular-expressions.info/anchors.html