Earlier quoted context omitted.
It’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.
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...
Regex character "$" doesn't mean "end-of-string"
331–340 of 382 posts
Re: Regex character "$" doesn't mean "end-of-string"
#332Earlier quoted context omitted.
Regexes 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 wo…
Regexes 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!
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!
Re: Regex character "$" doesn't mean "end-of-string"
#333Earlier quoted context omitted.
...and if you can understand them then you clearly understand regex enough not to need ChatGPT to write them
I understand assembly too.
Re: Regex character "$" doesn't mean "end-of-string"
#334Earlier quoted context omitted.
Yeah, omitting what is arguably the language most associated with regexes seems a bit of an oversight. I guess it shows how far off the radar Perl currently is.
> I guess it shows how far off the radar Perl currently is. This is a serious misconception. Perl is far, far from dead. The constant activity of the gargantuan CPAN library more than demonstrates very much the opposite. I would say Perl and its community has done quite well considering it hasn't had the same mountain of corporate funds thrust into it like more highlighted have. Mainstream ain't everything.
Re: Regex character "$" doesn't mean "end-of-string"
#335Re: Regex character "$" doesn't mean "end-of-string"
#336Earlier 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"
#337Earlier quoted context omitted.
re.match('^bob$', 'bob') → yes re.match('^bob$', 'bobs') → no Most people would expect 'bob\n' not to match, because I used '$' and it has an extra character at the end, just like 'bobs'. In Python it does match because '\n' is a special case.
... for some arbitrary definition of "most people".
Re: Regex character "$" doesn't mean "end-of-string"
#338Regexp was one of the first things I truly internalized years ago when I was discovering Perl (which still lives in a cozy place in my heart due to a lovely “Camel” book). Today 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…
How did you internalize it? Perl looks like cat keyboarding.
Re: Regex character "$" doesn't mean "end-of-string"
#339Earlier quoted context omitted.
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.
I am pretty sure even pure Awk can do it; or am I mistaken? I thought there was an even more sophisticated example in the Awk book. Edit: oh, you mean via regex engines available in GNU tools; I am dumb. Hmm... is there no GNU extension with PCRE?
It's a problem for Linux that it can't move on. The cold dead hand of gnu is firmly around the community's neck.
Re: Regex character "$" doesn't mean "end-of-string"
#340Earlier quoted context omitted.
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)
Why did they even decide to use two characters for the end of line? Seems bizarre. I could have imagined that `\r` and `\n` was a tossup. But why both?
Line Feed (\n) - move down 1 line
Essentially, when you're sending commands to teletypes, that's how you'd have to do it.