Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

16
  • You said "I am NOT interested in getting programs other than sed / grep / POSX extended REs to work." and then posted this answer using a program other than sed / grep / POSX extended REs. Commented Dec 25, 2023 at 15:13
  • Yes, but this was just an illustratory / exemplary answer, AFTER I had reached the final conclusion "No, there is no built-in way in GLIBC POSIX or in GNU grep / sed REs to handle an even/odd number of escape characters properly" . Commented Dec 26, 2023 at 18:02
  • After thinking about this for the last 3 days or so, I have reached the conclusion to develop a patch for both glibc and libc6 and grep and sed, that , for every POSIX character class, as a new GNU extension that can be enabled with the '/E' "Provide Escaped Char.Classes" modifier flag, will also provide an 'esc' suffixed variant of the char class that won't treat chars preceded by an ODD number of escapes as being part of the class, and maybe which will also have the sort of "number of elements test and conditional expression" logic described above. Commented Dec 26, 2023 at 18:03
  • The PCRE answer is a non-answer to this specific question, but illustrates the sort of solution that would be acceptable, if only we could do something as simple or simpler in POSIX / grep / sed RegExps , but we can't. Commented Dec 26, 2023 at 18:06
  • What's the point if you can already do whatever it is you want to do using perl? FWIW I still don't know what it is you're trying to do. If you provided sample input/output in your question that demonstrated all your requirements you may get an answer using existing POSIX tools and maybe it's not necessary to use a single regexp. Commented Dec 26, 2023 at 18:07