5 ms·
the idea of changing a decades old convention to instead use, as I assume you are implying, some character that requires special entry, is beyond silly.
by knome 3y ago
the idea of changing a decades old convention to instead use, as I assume you are implying, some character that requires special entry, is beyond silly.
- FranOntanaya 3y agoI don't think anyone that writes regex would feel specially challenged by using the Alt+ | Ctrl+Shift+u key combos for unicode entry. Having to escape less things in a pattern would be nice.
- amelius 3y agoAlso, code is read more often than it is written.
- cortesoft 3y agoPeople say this all the time, but is it really always true? I have a ton of code that I wrote, that just works, and I never really look at it again, at least not with the level of inspection that requires parsing the regex in my head.
- wccrawford 3y agoEven for code I wrote once and then never have to fix, I end up reading it multiple times while I create it and the lines around it. I think it really is always true.
- cortesoft 3y agoI write regexes all the time, and I don't know if I would be CHALLENGED by that, but it would be annoying. Escaping things is trivial, and since you do it all the time it is not anything extra to learn. Having to remember bespoke keystrokes for each character is a lot more to learn.
- keybored 3y agoASCII restriction begets ASCII toothpick soup. Either lift that restriction or use balanced delimiters for strings in ASCII like backtick and single quote. (“But backtick is annoying to type” said the Europeans.)
- int_19h 3y agoRegexes are one case where I think it's already extremely unbalanced wrt being easy to write but hard to read. Using stuff like special Unicode chars for this would make them harder to write but easier to read, which sounds like a fair deal to me. In general, I'd say that regexes should take time and effort to write, just because it's oh-so-easy to write something that kinda sorta works but has massive footguns. I would also imagine that, if this became the norm, IDEs would quickly standardize around common notation - probably actually based on existing regex symbols and escapes - to quickly input that, similar to TeX-like notation for inputting math. So if you're inside a regex literal, you'd type, say, \A, and the editor itself would automatically replace it with the Unicode sigil for beginning-of-string.
- emporas 3y agoRegexes originate from Perl, or they were popularized by Perl if i got this right. In Perl readable code is not ranked as one of it's top 100 priorities. Regexes could originate from J and situation could be even worse though!
- TristanBall 3y agoRegex's predate perl quite substantially. Think grep and friends if nothing else. Certainly making the perlre library available separate to perl encouraged its widespread use, and lots of others copied or were inspired by it. "Popularized" doesn't seem like quite the right word though, I don't disagree with the point, but if I shout "Hey everyone let's write regex's" at the office people throw stationary at me, which is not true of other popular things!
- 3y ago
- keybored 3y agoIt’s not that silly. You constantly get into escape conundrums because you need to use a metacharacter which is also a metacharacter three levels deep in some embedding. (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.
- LK5ZJwMwgBbHuVI 3y agoYes, 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...
- pepa65 3y agoThe weird characters are part of the syntax here. Of course, you can make it more verbose, or more flexible/configurable.
- keybored 3y agoFine 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”.
- keybored 3y agoOn 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.
- Karellen 3y agoIt 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.