I'm deeply puzzled by the way grep seems to parse a regex:
$ echo "@NS500287" | grep '^@NS500[0-9]{3}'
#nothing
$ echo "@NS500287" | grep '^@NS500[0-9]{3}'
@NS500287
That can't be right. Why am I escaping curly brackets that are part of a "match the previous, N times" component (and not, say, the square brackets as well)?
Shouldn't escaping be necessary only when I'm writing a regex that actually matches {
and }
as literal characters in the query string?
More of a cri de coeur than anything else, but I'm curious about the answer.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…