Earlier quoted context omitted.
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.
No gnu tool can balance brackets, afaics. So you can't do everything in sed. And sed is, by design, useless for matching text that spans lines, so good luck picking out paragraphs with it.
Regex character "$" doesn't mean "end-of-string"
71–80 of 382 posts
Re: Regex character "$" doesn't mean "end-of-string"
#72A reproducible example would be nice. I don’t understand what it is he cannot do. `re.search('$', 'no new lines')` returns a match.
Re: Regex character "$" doesn't mean "end-of-string"
#73Special 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.
FWIW, and I know this doesn't really address your complaint: I use Windows and I've set all my text editors to use LF exclusively years ago and Things Are Great. No more weird Git autocrlf warnings, no quirks when copying files over to/from people on Macs or Linuxes, etc. Even Notepad supports LF line endings for quite a long time now - to my practical experience, there's little remaining in Windows that makes CRLF "…
I don't know if it is the case on Windows 11, but I have surely been bitten by CMD batch files using LF line endings. I don't remember the exact issue but it may have been the one bug affecting labels. [1]
[1]: https://www.dostips.com/forum/viewtopic.php?t=8988#p58888
Re: Regex character "$" doesn't mean "end-of-string"
#74Earlier quoted context omitted.
"I will hire you anyway, but I will pay you less" Regex, useful in any job...
regex is useful but chatgpt is amazing at it, so why spend a minute keeping such useless knowledge in mind. if you know where to find something no point in knowing it.
Re: Regex character "$" doesn't mean "end-of-string"
#75Earlier quoted context omitted.
POSIX specifies two flavours of regular expressions: basic regular expressions (BRE) and extended regular expressions (ERE). There are subtle differences between the two and ERE supports more features than BRE. For example, what is written as a\(bc\)\{3\}d in BRE is written as a(bc){3}d in ERE. See https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1... for more details. The regular expression engines availab…
Indeed, and the most common is Perl since it was the source of many of the extensions.
Re: Regex character "$" doesn't mean "end-of-string"
#76Earlier quoted context omitted.
It's possible to get design decisions wrong. Clearly people expect `$` to only match end-of-string so they did make the wrong decision. It may not have been clear it was the wrong decision at the time.
Things are obviously more complicated than that, lines are a complicated issue for historical reasons. There are two conventions, line termination and line separation. In case of line termination, the newline is part of the line and a string without a newline is not a [complete] line. In case of line separation, the newline is not part of the line but separates two lines. Also the way newlines are encoded is not univ…
Re: Regex character "$" doesn't mean "end-of-string"
#77> 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.
> The ^ and $ language elements indicate the beginning and end of the input string. The end of the input string can be a trailing newline \n character.
Re: Regex character "$" doesn't mean "end-of-string"
#78Earlier quoted context omitted.
I don't think it is correct to say some get it right and some get it wrong, it is more of an design decision.
It's possible to get design decisions wrong. Clearly people expect `$` to only match end-of-string so they did make the wrong decision. It may not have been clear it was the wrong decision at the time.
ed -> sed
ed -> grep
The line oriented mature makes sense.There is some sed multi-line capability if one uses the hold space, but it is much easier to just use awk.
Re: Regex character "$" doesn't mean "end-of-string"
#79Earlier quoted context omitted.
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.
No gnu tool can balance brackets, afaics. So you can't do everything in sed. And sed is, by design, useless for matching text that spans lines, so good luck picking out paragraphs with it.
Edit: oh, you mean via regex engines available in GNU tools; I am dumb. Hmm... is there no GNU extension with PCRE?
Re: Regex character "$" doesn't mean "end-of-string"
#80> So if you're trying to match a string without a newline at the end, you can't only use $ in Python! My expectation was having multiline mode disabled wouldn't have had this newline-matching behavior, but that isn't the case. A reproducible example would be nice. I don’t understand what it is he cannot do. `re.search('$', 'no new lines')` returns a match.
re.match('^bob$', 'bob\n')
I didn't want the trailing newline to be included.