Regex doesn't check for end of line
1 answer
Special characters such as $
do not have the same meaning within a character class. In a character class, they are just characters, so [ $]
will match a space character or a character $
. It won't match the end of the line.
If you want to match a space character or the end of a line, you must use alternation, i.e. ( |$)
...
+6
source to share