Project

General

Profile

Actions

Bug #13140

closed

unmatched parenthesis error on regexp with "x" option when all parens are matched

Added by jdmeta (jake meta) about 7 years ago. Updated about 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.6p396 (2016-11-15 revision 56800) [i386-mingw32]
[ruby-core:79182]

Description

See the attached source file.

When the attached file is executed as is, the following error is emitted:
test.rb:39: end pattern with unmatched parenthesis: /^(%([^%]+)%)?+((_?+)([^#]+))(#|$)/x

There are no unmatched parens in the regex.

The error also occurs in the following scenarios:

  • Spaces are inserted into the regex.
  • The %r{} literal is used. It's interesting that in this scenario, the error message displayed is identical to the
    one above, i.e. the forward slashes appear in the error message even though the source uses %r{}.
  • The section array is moved above the row array (note the presence of the regex using an x option on line 30).

The error does not occur in any of the following scenarios:

  • The x option is removed.
  • The x option is replaced with the i option.
  • The x option is replaced with the m option.

Files

test.rb (1.01 KB) test.rb jdmeta (jake meta), 01/20/2017 04:40 AM

Updated by jdmeta (jake meta) about 7 years ago

Realized the problem.
The error is caused because the x option also ignores text after # and two # appear in the regex.
If these are escaped then the error goes away.

Actions

Also available in: Atom PDF

Like0
Like0Like0