On 2021-03-26 6:15 p.m., B. Estrade wrote: > Apologies for another post, but rather than as, "well what single regex would > replace this" it was easy enough for me to just figure it out: > > perl -e '$x=" foo "; $x =~ s/^\s*([^\s]*)\s*$/$1/; print $x' Its more like replacing this: print $x =~ s/^\s*(.*?)\s*$/r; Your version seems to have the error in that it wouldn't do anything for inputs that also have whitespace in the middle, such as if we want to trim " foo bar " and get "foo bar". -- Darren DuncanThread Previous | Thread Next