338
submitted 7 months ago by pmjv@lemmy.sdf.org to c/linuxmemes@lemmy.world
you are viewing a single comment's thread
view the rest of the comments
[-] 2xsaiko@discuss.tchncs.de 9 points 7 months ago

None of these examples are for parsing English sentences. They parse completely different formal languages. That it's text is irrelevant, regex usually operates on text.

You cannot write a regex to give you for example "the subject of an English sentence", just as you can't write a regex to give you "the contents of a complete div tag", because neither of those are regular languages (HTML is context-free, not sure about English, my guess is it would be considered recursively enumerable).

You can't even write a regex to just consume <div> repeated exactly n times followed by </div> repeated exactly n times, because that is already a context-free language instead of a regular language, in fact it is the classic example for a minimal context-free language that Wikipedia also uses.

[-] Blue_Morpho@lemmy.world -5 points 7 months ago* (last edited 7 months ago)

None of these examples are for parsing English sentences.

Read it again:

"At one point while working on the manuscript for this book. I ran such a tool on what I’d written so far"

The author explicitly stated that he used regex to parse his own book for errors! The example was using regex to parse html.

You can’t even write a regex to just consume repeated exactly n times followed by repeated exactly n times,

Just because regex can't do everything in all cases doesn't mean it isn't useful to parse some html and English text.

It's like screaming, "You can't build an Operating system with C because it doesn't solve the halting problem!"

this post was submitted on 29 Feb 2024
338 points (96.2% liked)

linuxmemes

21041 readers
650 users here now

Hint: :q!


Sister communities:


Community rules (click to expand)

1. Follow the site-wide rules

2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack members of the community for any reason.
  • Leave remarks of "peasantry" to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
  • 3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
  • 4. No recent reposts
  • Everybody uses Arch btw, can't quit Vim, and wants to interject for a moment. You can stop now.

  • Please report posts and comments that break these rules!

    founded 1 year ago
    MODERATORS