From: leo@... Date: 2016-10-22T22:59:09+00:00 Subject: [ruby-core:77718] [Ruby trunk Bug#12862] Regular Expression Named Group Matching does not work with #{} (Similar? to issue #2778) Issue #12862 has been updated by Leo Amigud. Hans Mackowiak wrote: > it did took me a while to understand what you mean, because the regexp are displayed wrong. > > "When named capture groups are used with a literal regexp on the left-hand side of an expression and the =~ operator, the captured text is also assigned to local variables with corresponding names." > > it might not be good explained, but that literal regexp can not have interpolation for that to work. Sorry, not sure what you mean. As a matter of fact i can use regexp like: irb(main):013:0> numbers = '\d+' => "\\d+" irb(main):014:0> /\$#{numbers}.\d+/ =~ "$3.67" => 0 irb(main):015:0> to match the string, but using #{numbers} inside the named group somehow does not work. Is that the expected behaviour? Leo ---------------------------------------- Bug #12862: Regular Expression Named Group Matching does not work with #{} (Similar? to issue #2778) https://bugs.ruby-lang.org/issues/12862#change-61001 * Author: Leo Amigud * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- Loading development environment (Rails 4.2.5) irb(main):001:0> /\$(?\d+)\.(?\d+)/ =~ "$3.67" => 0 irb(main):002:0> dollars => "3" BUT: irb(main):001:0> numbers = '\d+' => "\\d+" irb(main):002:0> /\$(?#{numbers})\.(?\d+)/ =~ "$3.67" => 0 irb(main):003:0> dollars NameError: undefined local variable or method `dollars' for main:Object -- https://bugs.ruby-lang.org/ Unsubscribe: