On 20.9. 21:39, Chet Ramey wrote:

The portion of the manual before the example explains BASH_REMATCH and
BASH_REMATCH[0]. It also says "a sequence of characters in the value..."
when describing the pattern.

Yeah, though the preceding paragraph contains both the general description of the regex match, and the mention of BASH_REMATCH, so the BASH_REMATCH angle could be a bit more explicit.

So I'd probably say that the pattern would match e.g. 'xxx aabyyy', or 'xxxbyyy' and set $BASH_REMATCH to ' aab', or 'b', respectively. And then mention that the ^ and $ anchors could be used.

I know the usual regex behavior is to find a match anywhere within the value, but since it's exactly the opposite of how regular pattern matches work, it's probably worth mentioning in some way. (Though I do think it's better to document things rather explicitly in general.)


--
Ilkka Virta / itvi...@iki.fi

Reply via email to