Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

fix escaping of exclude arg#35

Open
yufukui-m wants to merge 2 commits intocodenize-tools:0.3.0from
yufukui-m:fix_escape_exclude
Open

fix escaping of exclude arg#35
yufukui-m wants to merge 2 commits intocodenize-tools:0.3.0from
yufukui-m:fix_escape_exclude

Conversation

@yufukui-m
Copy link

we need to more escape backslashes

irb(main):001:0> name = 'foobar'
=> "foobar"
irb(main):002:0> re = Regexp.new("\A#{Regexp.escape(name)}\z")
=> /Afoobarz/
irb(main):003:0> re.match('foobar')
=> nil
irb(main):004:0> re.match('Afoobarz')
=> #<MatchData "Afoobarz">
irb(main):005:0> re = Regexp.new("\\A#{Regexp.escape(name)}\\z")
=> /\Afoobar\z/
irb(main):006:0> re.match('foobar')
=> #<MatchData "foobar">

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant