in reply to Regex Search pattern not terminated error

Hello neilwatson,

You are right about two things:

  1. the problem expression is \Q:{\E
  2. \Q ... \E (and quotemeta) do indeed escape braces (curly brackets) along with the other regular expression metacharacters.

What’s happening here (and it took me a while to figure it out!) is that the qr expression is also using braces as its delimiter. So the Perl parser first looks for the end of the whole qr{...} expression, and thinks it has found it when it encounters the first right brace; only later does it implement \Q ... \E to backslash non-word characters.

To fix this, either escape the brace manually (\Q:\{\E) or (better) change the delimiter: my $regex = qr! \n ... !mix;

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,