I'm trying in Python to "clean up" a string and remove some characters that were added like :
"1. bla bla" => i want "bla bla"
"#. bla bla" => same
"3) bla bla" => same
"I. bla bla" => same
I tried to use (\W)(\w.*) but doesn't work.
Thanks !
CodePudding user response:
You can try:
^.[.)]\s (.*)
import re
text = """\
1. bla bla
#. bla bla
3) bla bla
I. bla bla"""
pat = re.compile(r"^.[.)]\s (.*)", flags=re.M)
for cleaned in pat.findall(text):
print(cleaned)
Prints:
bla bla
bla bla
bla bla
bla bla
CodePudding user response:
You can try this demo
(\")[^ ]* ([^\"]*\")