From: jdmeta@... Date: 2017-01-20T05:08:04+00:00 Subject: [ruby-core:79183] [Ruby trunk Bug#13140] unmatched parenthesis error on regexp with "x" option when all parens are matched Issue #13140 has been updated by jake meta. 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. ---------------------------------------- Bug #13140: unmatched parenthesis error on regexp with "x" option when all parens are matched https://bugs.ruby-lang.org/issues/13140#change-62606 * Author: jake meta * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.2.6p396 (2016-11-15 revision 56800) [i386-mingw32] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- 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) -- https://bugs.ruby-lang.org/ Unsubscribe: