In Regular Expressions Quick Start, it reads
Twelve characters have special meanings in regular expressions: the backslash \, the caret ^, the dollar sign $, the period or dot ., the vertical bar or pipe symbol |, the question mark ?, the asterisk or star *, the plus sign +, the opening parenthesis (, the closing parenthesis ), the opening square bracket [, and the opening curly brace {. These special characters are often called "metacharacters". Most of them are errors when used alone.
In its specification, ()
, [
,{
are metacharacters whereas 'closing sqare bracket' and 'closing curly brace' are not.
Obviously,[
and {
unable to take an effect individually just like opening parenthesis (
should partners )
.
What's the reason that causes ]
and }
failing to be selected?
)
doesn't fit into the same category as}
,]
and-
. Is there a reason for this inconsistency? – David Arno Dec 07 '17 at 10:21)
. I never noticed that, probably because you rarely get tings starting with)
. By my logic they should be able to deal with it, since it's unambiguously a normal character. I'm not sure why alternative-processing parsers tend to be pickier than the character-class parsers. Maybe it's because character-class logic is a lot simpler and more straightforward to implement? – Kilian Foth Dec 07 '17 at 10:36[]
and{}
tend to only contain a few characters between them, so mistakes can be easier to spot.()
can be nested and contain large sections of an expression, so spotting erroneous)
's could be more difficult. Pure speculation though. – David Arno Dec 07 '17 at 10:59