Method: Interscript::Stdlib.parallel_regexp_gsub

Defined in:
lib/interscript/stdlib.rb

.parallel_regexp_gsub(string, subs_regexp, subs_hash) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/interscript/stdlib.rb', line 40

def self.parallel_regexp_gsub(string, subs_regexp, subs_hash)
  string.gsub(subs_regexp) do |match|
    lm = Regexp.last_match
    # Extract the match name
    idx = lm.named_captures.compact.keys.first[1..-1].to_i
    subs_hash[idx]
  end
end