Reputation: 3908
I am trying to learn python but don't quite understand the syntax. What is the equivalent of:
my $string='this one this that this here ';
while($string=~/this\s+(.*?)\s+/g){
print $1."\n";
}
prints:
one
that
here
Upvotes: 4
Views: 142
Reputation:
Try the re
module. I think this is equivalent, modulo some of the side-effects on string
:
import re
string = "this one this that this here "
for match in re.finditer(r"this\s+(.*?)\s+", string):
print match.group(1)
Upvotes: 7