0

I'm trying to split this text:

"Hi stackoverflow.I need to split these sentences.By full stop."

into something like this:

["Hi stackoverflow.", "I need to split these sentences.", "By full stop."]

I've tried the following:

import regex as re
text = "Hi stackoverflow.I need to split these sentences.By full stop."
re.findall(".*?\.[a-zA-Z0-9].*?", text)

but it returns:

['Hi stackoverflow.I', ' need to split these sentences.B']
ranni rabadi
  • 194
  • 2
  • 9
  • You may use: `re.findall(r".+?\.(?=[A-Z]|$)", text)` – anubhava Sep 28 '22 at 06:51
  • 1
    `re.findall(".+?\.", text)` – vaizki Sep 28 '22 at 06:51
  • 1
    Could there be any dot in a number you would need to leave alone? For example `"Version 2.0"`? Would it be saver to assume a full stop is followed by uppercase letters? For example `re.split(r'(?<=\.)(?=[A-Z])', text)` – JvdV Sep 28 '22 at 06:52

0 Answers0