-5

What are the differences between GNU grep's basic/extended and PCRE regular expressions?

To me this is a clear-cut question asking for the differences between different modes of a single program, but close-voters have not given me any details on why they think it is not focused.

"Needs more focus" close reason states:

This question currently includes multiple questions in one. It should focus on one problem only.

So what about my question is multiple questions in one?

20
  • 6
    "Not focused" is the new "too broad", and sometimes it's still used for the original reason (further reading: Do we really need more focus?).
    – Andrew T.
    Commented Jun 10, 2021 at 18:11
  • 5
    How is the question too broad then? Is asking the differences between different grep modes really too broad of a question?
    – qwr
    Commented Jun 10, 2021 at 18:15
  • 1
    I am not really a subject matter expert here but I would say the documentation you yourself linked seems to answer your question? See: "Perl-compatible regular expressions give additional functionality, and are documented in the pcresyntax(3) and pcrepattern(3) manual pages" This seems to suggest that PCRE has some additional functionality compared to ERE and further tells what man page to look to for those functionalities. Commented Jun 10, 2021 at 18:28
  • @AbdulAzizBarkat ah but it does not specify what are the differences, which is the crux of the question.
    – qwr
    Commented Jun 10, 2021 at 18:30
  • Won't the additional functionalities themselves be the differences? Commented Jun 10, 2021 at 18:30
  • @AbdulAzizBarkat the manpages for PCRE to my untrained eye look the same as the grep manpages, which is why the question is needed in the first place!
    – qwr
    Commented Jun 10, 2021 at 18:32
  • 12
    I haven't voted, but PCRE functionality is about an order of magnitude larger than BRE/ERE, so listing the differences is almost the same as answering "what can you do with PCRE", and a glance at the massive man page for pcrepattern would indicate that this is a broad question indeed. Commented Jun 10, 2021 at 18:35
  • 2
    I only knew of the superficial syntax differences which my question was based on
    – qwr
    Commented Jun 10, 2021 at 18:44
  • 2
    It also reads to my untrained/ non-SME eye partially like you're looking to compare three things (GNU grep basic, GNU grep extended, and PCRE regular expressions), rather than two (GNU grep basic & extended vs. PCRE RegEx), which may also cause some voters to trip.
    – zcoop98
    Commented Jun 10, 2021 at 18:58
  • 2
    I should clarify that PCRE is a mode within grep
    – qwr
    Commented Jun 10, 2021 at 19:03
  • 2
    Answers to such questions require high maintenance as they tend to get outdated quickly. I personally downvote and cast a close vote on those questions, because 1. I don't want to maintain such a broad thread, 2. I don't want to see that thread at the top every day. Both BRE and ERE are standardized in POSIX, you can just go read about them. And PCRE is a whole other world. Commented Jun 11, 2021 at 17:39
  • 4
    @oguzismail your responses don't make sense to me. 1. no one is asking you to maintain the answers, so not a valid reason for closure. 2. not a valid reason for closure.
    – qwr
    Commented Jun 11, 2021 at 20:40
  • 3
    Why'd you delete it? It's technically still being discussed and it looked like there some reopen votes cast on it.
    – Makoto
    Commented Jun 11, 2021 at 22:33
  • 1
    Fine, I undeleted it. But I thought it was just attracting negative attention at that point.
    – qwr
    Commented Jun 11, 2021 at 23:25
  • 1
    @qwr Well, to me they are. Because I know it is going to attract useless answers that'll only help those who can't be bothered to read a manual for some time, and then eventually get outdated. Almost all list this list that compare this to that questions are like that and they have no value & should be closed and deleted. Commented Jun 12, 2021 at 3:52

1 Answer 1

-2

Looking at a question like this, I usually like to seek out prior art that does a good job of not being tainted by either its age or its questionable topicality.

Seems like there's a decent number of practical questions asking for comparisons between two different and explicit things.

All of these questions have hallmarks we generally like:

  • They're in-context and not philosophical; someone would benefit from knowing the difference between these.
  • There's reason for ambiguity; examples or patterns may see one way, the other way or both ways applied in a code base with little rhyme or reason.
  • There are advantages or limitations in choosing one approach over another. Speaking strictly from a Java mind, using Hashtable is almost never preferred to using HashMap unless there were some really draconian concurrency requirements (and there are still probably better ways to do it even then).

In the context of grep, which is a very widely used tool, there are likely some circumstances in which using "normal" grep (e.g. no regex required) is disadvantageous to using grep with the extensions (e.g. grep -E) or using the Perl variant (grep -P). There are some systems which still run using Perl that have assumptions about either the way data is shaped or the way data is parsed, and perhaps the Perl extension is the right way to query that.

So that said, I would find value in something comparing the feature sets of these two together.

But I'm not an expert in regex, nor do I even want to play one on TV (doesn't pay well enough). It's up to the community if they would want to support or answer a question like this, but from where I'm sat, I see no real reason not to answer the question.

2
  • 2
    I'm glad common sense still exists among some SO users. I have a self-answer prepared if my question is reopened.
    – qwr
    Commented Jun 12, 2021 at 1:13
  • 2
    Self answering doesn't exempt any question from quality standards @qwr
    – Braiam
    Commented Jun 12, 2021 at 11:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .