I read somewhere that the caret ^ and dollar $ (more so the dollar) are vulnerable when using regular expressions to validate user input.
I believe you interpreted the article wrongly. What vulnerability does it state?
Interesting, I'm aware of the differece between multi line and single lines, but in the discussion I observed their examples didn't include the m modifier.
Perhaps you missed:
In Perl, you do this by adding an m after the regex code, like this: m/regex$/m;.
If you are talking about:
Let's see what happens when we try to match 4$ to 749\n486\n4 (where \n represents a newline character) in multi-line mode.
Then I note that 4$ is an incomplete PCRE pattern to begin with since it lacks delimiters, and for this example a correct full pattern would be: /4$/m
If this is what you refer to by "vulnerability", then I must say it is not: clearly the third line matches the pattern. If one intends to match the entire string against '4', then of course this is wrong in multi-line mode. On the other hand, if one wants to match a line against '4', then /\A4\Z/m is wrong. So, perhaps regex is inherently vulnerable? 😉