fork download
  1. text = 'am pm P.M. 10:56pm 10:43 a.m.'
  2. rx = /\b((?:[01]?[0-9]|[2][0-3]):[0-5][0-9]\s*[pa]\.?m\b\.?)|\b[ap]\.?m\b\.?/i
  3. result = text.gsub(rx) { $1 || "\n" }
  4. p result
Success #stdin #stdout 0s 28224KB
stdin
Standard input is empty
stdout
"\n \n  \n  10:56pm 10:43 a.m."