Regex character "$" doesn't mean "end-of-string"
sethmlarson.dev
Regex character "$" doesn't mean "end-of-string"
1–10 of 382 posts
Re: Regex character "$" doesn't mean "end-of-string"
#2Re: Regex character "$" doesn't mean "end-of-string"
#3this is mostly due to the different types of regex and less about it being platform dependent. $ was end of string in pcre which is the "old" perl compatible regex. python has its own which has quirks as mentioned, re2 is another option in go for example, and i think rust has its own version as well iirc.
Re: Regex character "$" doesn't mean "end-of-string"
#4Re: Regex character "$" doesn't mean "end-of-string"
#5Re: Regex character "$" doesn't mean "end-of-string"
#6I'm confused by this blog-post. In the table: what is the reg-ex pattern tested and against which input?
"cat$" with multiline enabled
"cat$" with multiline disabled
"cat\z"
"cat\Z"Re: Regex character "$" doesn't mean "end-of-string"
#7Re: Regex character "$" doesn't mean "end-of-string"
#8Today most important bit of information is knowledge that implementations differ and I made a habit of pulling reference sheet for a thing I work with.
E.g. Emacs Regexp annoyingly doesn’t have word in form of “\w” but uses “\s_-“ (or something no reference sheet on screen) as character class (but Emacs has the best documentation and discoverability - a hill I’m willing to die on)
Some utilities require parenthesis escaping and some not. Sometimes this behavior is configurable and sometimes it’s not.
I lived through whole confusion, annoyance, denial phase and now I just accept it. Concept is the same everywhere but flavor changes.
Re: Regex character "$" doesn't mean "end-of-string"
#9The new-line character is an actual character "at the end" of the string though so it makes sense that $ would include the new-line character in multi-line matching.
I'm not too surprised by PHP and Python getting it wrong. Java and C# is a slight surprise though.
Re: Regex character "$" doesn't mean "end-of-string"
#10The new-line character is an actual character "at the end" of the string though so it makes sense that $ would include the new-line character in multi-line matching.