Actions
Feature #12700
openregexg heredoc support
Status:
Open
Assignee:
-
Target version:
-
Description
There is support for ', ", and ` heredocs, but there is no support for /.
Example code with new feature:
first = 'first'
orig = /#{first}
match\s # match
this # match this
/x
right = <</REGEXP/x
#{first}
match\s # match
this # match this
REGEXP
raise unless orig == right
There is no straight forward way to replace a regexp heredoc as a double quote heredoc requires that '\s' be escaped.
As shown in the code below you can't use the string heredoc to directly replace a regexp heredoc because of this need for extra escaping.
first = 'first'
orig = /#{first}
match\s # match
this # match this
/x
wrong = Regexp.new(<<REGEXP, Regexp::EXTENDED)
#{first}
match\s # match
this # match this
REGEXP
right = Regexp.new(<<REGEXP, Regexp::EXTENDED)
#{first}
match\\s # match
this # match this
REGEXP
raise unless orig != wrong
raise unless orig == right
Files
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0