fork(1) download
  1. rx = /\bgrouping(\((?>[^()]|(\g<1>))*+\))/
  2. txt = "grouping(elllo)\n\ngrouping(function() {\n console.log(\"hello\")\n})"
  3. puts txt.gsub(rx) { |m| m.gsub($~[1], '(NEWTEXT)') }
Success #stdin #stdout 0.01s 7464KB
stdin
Standard input is empty
stdout
grouping(NEWTEXT)

grouping(NEWTEXT)