I used a non-greedy(lazy) +?
operator but it is being greedy
I expect the RE \S+?@\S+
when matched against the string 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
to match 'd@uct.ac.za'
, but it matched 'stephen.marquard@uct.ac.za'
.
Below is the Python code I used.
import re
string = 'From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008'
out = re.findall('\S+?@\S+', string)
print(out)
When I tried the same string and pattern in Notepad++, I got the same result.