Project

General

Profile

Actions

Bug #10539

closed

Wrong pattern matching when string interpolation inside regexp is used

Added by tammo (tammo tjarks) almost 10 years ago. Updated almost 10 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
[ruby-core:66437]

Description

Hello,
maybe it is my fault, but I stumble over the fact, that I get a match when I should not (have added a short example).
I use an Array to have a list of matching names like:

a = ['moin','test','whatever']

and when I compare with
strings like

ex_strings = ["TOMATCH moin","SHOULNDTMATCH whatever"]

I get with

str =~ /TOMATCH #{a.join("|")}/

(see attached example) a match for TOMATCH moin as well
as SHOULDNTMATCH whatever. I tried it with other versions as well.
I tried it with older versions of ruby as well with the same result.
Is the use of string Interpolation inside regular expressions problematic?

Best regards,
Tammo


Files

example.rb (178 Bytes) example.rb tammo (tammo tjarks), 11/24/2014 03:57 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0