I'm trying to find strings that have trailing whitespace, i.e. 'foo ' as opposed to 'foo'.
In Perl, I would use:
$str = 'foo ';
print "Match\n" if ($str =~ /\s+$/) ;
When I try this in Python 2.6, e.g.:
import re
str = 'foo '
if re.match('\s+$', str):
print 'Match'
it doesn't match. I feel like I'm missing something obvious but I can't figure out what I'm doing wrong.
r'\s+$'
where 'r' is before the quotes. This prevents python from treating escaped characters as special.