jeudi 24 janvier 2019

regex for alternate repetition of words [duplicate]

This question already has an answer here:

I want to find 'the phone' pattern but it's couting only one the phone in given line :

pat=r'\sthe\sphone\s'
line=' the phone the phone '

If I give input string with extra space ==' the phone the phone ' the only it will print expected output ['the phone' ,'the phone']

ssss=re.findall(pat,line,re.IGNORECASE)

print(ssss)

output [' the phone ']

I'm using python for this regular expression:

{pat=r'\sthe\sphone\s'

line=' the phone the phone '

ssss=re.findall(pat,line,re.IGNORECASE)

print(ssss)}

Aucun commentaire:

Enregistrer un commentaire