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
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.