fork download
  1. str = "John: hey, what's your name?.. :haha \n Stella: :foo :xx: my name is ... stella :xx:"
  2. ary = [":haha", ":xx:", ":foo", ":bar"]
  3. print str.gsub(Regexp.new("#{ary.join('|')}")) { |w| "(.*)" }.gsub( /(?>\(\.\*\)|[^\w ]+)/, "(.*)").gsub(/\(\.\*\)(?>\s*\(\.\*\))*/,"(.*)")
Success #stdin #stdout 0.01s 7464KB
stdin
Standard input is empty
stdout
John(.*) hey(.*) what(.*)s your name(.*) Stella(.*) my name is (.*) stella (.*)