Am Dienstag, 22. April 2014 um 10:11:34, schrieb Richard Heck <[email protected]> > On 04/22/2014 06:01 AM, Kornel Benko wrote: > > > > Am Dienstag, 22. April 2014 um 11:54:09, schrieb Jürgen Spitzmüller > > <[email protected]> > > > > > > Why the extra "\s*" ? > > > > > > > > > > > > > > > > I cannot remember. This is 7 year old code. Most likely I just took an > > > > > existing regexp as a model. > > > > Actually, the existence of this extra code was also the reason why I > > thought that > > > > the intent in the original version was to remove the trailing white space. > > > > I assume that must have been the intent: > > re.compile(r'\s*(\S.*)\s*$') > re.compile(r'\s*(\S.*)$') > > But of course it will not remove whitespace, since .* is greedy and eats > as much as possible, which means: to the end of the line. If one did > want to remove trailing whitespace, then: > re.compile(r'\s*(\S.*?)\s*$') > Now .*? eats as little as possible, so up until the trailing whitespace. >
Oh, interesting.
> Richard
Kornel
signature.asc
Description: This is a digitally signed message part.
