I would like to patch some text data extracted from web pages. sample:
t=\"First sentence. Second sentence.Third sentence.\"
There is no sp
You can backreference in the substitution string with \1
(to match capture group 1).
t = "First sentence. Second sentence.Third sentence!Fourth sentence?Fifth sentence."
t.gsub(/([.!?])([A-Z1-9])/, "\\1\n\\2") # => "First sentence. Second sentence.\nThird sentence!\nFourth sentence?\nFifth sentence."