How to extract a substring after keyword am
, is
or are
from a string but not include am
, is
or are
?
string = 'I am John'
I used:
re.findall('(?<=(am|is|are)).*', string)
An error occurs
re.error: look-behind requires fixed-width pattern
What is the correct approach?
import re
s = 'I am John'
g = re.findall(r'(?:am|is|are)\s+(.*)', s)
print(g)
Prints:
['John']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With