- 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
7 Réponses
+ 8
All you need to do is writing :
print("wicked stepmother, 1989, as miranda")
>>> wicked stepmother, 1989, as miranda
+ 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())
+ 1
you are level one and tell level 11 you I think you haven't started using this app or learn Python.
0
@jaya i think so you haven't learn python 😒😒😒.
0
awesome visph! I will try it. thanks for ur response
0
thanks a ton visph. it worked
- 4
@hasan.. I think you haven't started using this app or learn Python