Re:Regex character "$" doesn't mean "end-of-string"
by LK5ZJwMwgBbHuVI on Wednesday March 20, 2024 @01:42PM
(#39769798)
Yes, languages really need some sort of "raw string" feature like Python (or make regex literals their own syntax like Perl does). That's the solution here, not using weird characters...
Re:Regex character "$" doesn't mean "end-of-string"
by keybored on Thursday March 21, 2024 @04:24AM
(#39775991)
Fine enough. But I wonder why strings have to use the same delimiter. Imagine if you had a list delimiter `|` and the answer to nested lists was “ohh, use raw list syntax, just make `###||` when you are three levels deep or something”.
Re:Regex character "$" doesn't mean "end-of-string"
by keybored on Thursday March 21, 2024 @09:53AM
(#39778513)
On the third hand strings are of course a special case because you always have special characters and whatnot which makes raw strings useful. :) Not just doing `"` and stuff.
Re:Regex character "$" doesn't mean "end-of-string"
by Karellen on Friday March 22, 2024 @10:57AM
(#39791358)
It is quite nice what `sed` does. A sed search-and-replace is typically shown as `s/foo/bar/`, but you can actually use any punctuation character to separate the parts. Whatever follows the "s" will be used for that statement, so you can write `s|foo|bar|` or `s:foo:bar:`, even mixing and matching in the same script to have `s|baz|quux|; s:xyzzy:blorp:` and it will all work.
(But that might not solve that problem? Maybe the problem is mostly about using same-character delimiters for strings.)
And I guess that’s why Perl is so flexible with regards to delimiters and such.