fork download
  1. p 'google.translate(en, fr) this is a test'.match(/^(.+)(\((.*)\)) ?(.*)$/)
  2. # I want to make the parenthesis part optional, what's happening?
  3. p 'google.translate(en, fr) this is a test'.match(/^(.+)(\((.*)\))? ?(.*)$/)
Success #stdin #stdout 0.01s 7420KB
stdin
Standard input is empty
stdout
#<MatchData "google.translate(en, fr) this is a test" 1:"google.translate" 2:"(en, fr)" 3:"en, fr" 4:"this is a test">
#<MatchData "google.translate(en, fr) this is a test" 1:"google.translate(en, fr) this is a test" 2:nil 3:nil 4:"">