-
-
Save ephesus/8f6ca6e364443cfc7d48 to your computer and use it in GitHub Desktop.
implement \1 captures manually in gsub block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#I have no idea what the correct way to do this is | |
#couldn't use .gsub(regex, 'need \1') because sometimes I needed to format the capture | |
#so i implmented it in a block to gsub | |
tex.gsub!(regex) do | |
res = "thing with \1 and \2 and \3" | |
Regexp.last_match.captures.each_with_index do |match, i| | |
if match =~ /^請求項[\p{N},~、-及びおよ]+$/ | |
res = res.gsub(/\\#{i+1}/, format_invention_according_to(match)) | |
else | |
res = res.gsub(/\\#{i+1}/, match) | |
end | |
end | |
res | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment