- 1

How to split a sentence using regular expressions?

I have a sentence." Wicked stepmother (1989) as miranda". i have to split it into three parts so that output will be "wicked stepmother, 1989, as miranda". how to do this with regular expression

1st Mar 2017, 5:06 AM
Jayabalan Bala
Jayabalan Bala - avatar
7 Respuestas
+ 8
All you need to do is writing : print("wicked stepmother, 1989, as miranda") >>> wicked stepmother, 1989, as miranda
1st Mar 2017, 8:49 AM
Hassan Amr
Hassan Amr - avatar
+ 4
""" Basic version: without handling possible spaces ^^ - not working if spaces between parenthesis and numbers - don't "trim" sub-parts - works for any digit length numbers ( at least one ) ... could be improved in any way, obiously """ import re t = 'Wicked stepmother (1989) as miranda' r = re.compile("^(.*)\((\d+)\)(.*)
quot;) print(r.search(t).groups())
1st Mar 2017, 6:59 PM
visph
visph - avatar
+ 1
you are level one and tell level 11 you I think you haven't started using this app or learn Python.
1st Mar 2017, 2:12 PM
king shehab
king shehab - avatar
0
@jaya i think so you haven't learn python 😒😒😒.
1st Mar 2017, 2:11 PM
king shehab
king shehab - avatar
0
awesome visph! I will try it. thanks for ur response
1st Mar 2017, 7:01 PM
Jayabalan Bala
Jayabalan Bala - avatar
0
thanks a ton visph. it worked
1st Mar 2017, 7:07 PM
Jayabalan Bala
Jayabalan Bala - avatar
- 4
@hasan.. I think you haven't started using this app or learn Python
1st Mar 2017, 1:08 PM
Jayabalan Bala
Jayabalan Bala - avatar