Does anyone consider RegEx to be standardised? Moving to a new context is always a relearning exercise in my experience.
My understanding is it was standardised for Posix but the variants in popular use have so many variations. I consider sed to be the baseline. If you can do sed you can do anything but it’s seriously limited.
Regex character "$" doesn't mean "end-of-string"
51–60 of 382 posts
Re: Regex character "$" doesn't mean "end-of-string"
#52> Note: The table of data was gathered from regex101.com, I didn't test using the actual runtimes. Has anyone confirmed this behaviour directly against the runtimes/languages? Newlines at the end of a string are certainly something that could get lost in transit inside an online service involving multiple runtimes.
In what way could newlines at the end of a string "could get lost in transit"?
Re: Regex character "$" doesn't mean "end-of-string"
#53It must be some kind of philosophical objection because there's no way something with as much water under the bridge as Python simply hasn't got around to it.
Re: Regex character "$" doesn't mean "end-of-string"
#54Earlier quoted context omitted.
Languages invented after Perl will generally use some flavor of Perl regex syntax, but there are always some minor differences. The issue of the meaning of `$` and changing it via multi-line mode is usually consistent though.
I like to think of "whatever browsers do in js" as an updated common baseline. Whatever your regex engine does, describe it as a delta to the js precedent. That thing is just so ubiquitous. I do wonder though what's the highest number of different regex syntaxes I've ever encountered (perhaps written?) within a single line: bash, grep and sed are never not in a "hold my beer" mood!
I've got "hold my beer" commits in .net - I've balanced brackets. I believe that's impossible in sed and grep. If I were going to write a json parser in a script, then a) stop me and b) it's got to be in powershell.
Re: Regex character "$" doesn't mean "end-of-string"
#55> Folks who've worked with regular expressions before might know about ^ meaning "start-of-string" and correspondingly see $ as "end-of-string". Huh. I always think of them as "start-of-line" and "end-of-line". I mean, a lot of the time when I'm working with regexes, I'm working with text a line at a time so the effect is the same, but that doesn't change how I think of those operators. Maybe because a fair amount of…
Same, tho it'd be interesting to see if this behavior holds if the file ends without a trailing newline and your match is on the final newline-less line.
$ printf 'Line with EOL\nLine without EOL' | grep 'EOL$'
Line with EOL
Line without EOL
$ grep --version | head -n1
grep (GNU grep) 3.8Re: Regex character "$" doesn't mean "end-of-string"
#56Special misery case: Visual Studio supports regex search, where '$' matches \n. The end of line character is usually the standard Windows \r\n. Yes, that means if you want to really match the end of line you have to match "\r$". So broken.
The whole \r is archaic. It doesn't even behave properly in most cases. Just use \n everywhere and bite the lemon for a short while to fix your problems. And if you believe \r\n is the way to go, please make sure \n\r also works as they should have the same results. (or \r\n\r\r\r\r for that matter)
Re: Regex character "$" doesn't mean "end-of-string"
#57> Folks who've worked with regular expressions before might know about ^ meaning "start-of-string" and correspondingly see $ as "end-of-string". Huh. I always think of them as "start-of-line" and "end-of-line". I mean, a lot of the time when I'm working with regexes, I'm working with text a line at a time so the effect is the same, but that doesn't change how I think of those operators. Maybe because a fair amount of…
Vim is what did that for me.
Re: Regex character "$" doesn't mean "end-of-string"
#58I can hear thousands of bad hiring manager's adding 'How do you match the end of a string in a regex?' to their list of 'Ha! You don't know the trick!' questions designed to catch out candidates.
Regex, useful in any job...
Re: Regex character "$" doesn't mean "end-of-string"
#59Does anyone consider RegEx to be standardised? Moving to a new context is always a relearning exercise in my experience.
The three big ones I know of are POSIX, Perl/PCRE(aka Perl-Compatible Regular Expression), and Go came along and added used re2, which is a bit different from the first too. A lot of systems implemented PCRE, including JavaScript, since Perl extended the POSIX system with many useful extensions. IIRC, re2 tries to reign in on some of the performance issues and quirks the original systems had, while implementing the w…