in reply to Re^2: Way to "trim" part of a phrase?
in thread Way to "trim" part of a phrase?

Never mind - there was a typo in your regex (you had ^ inside the [ bit =)) This works:
my $string = q|pour 2 personnes, achetez deux motos tout le monde je p +répare un un projet de voyage assez similaire|; print qq|OLD STRING: $string \n|; $string =~ s/[^\.!\,\:\)]+[\.!\,\:\)]//; print qq|NEW STRING: $string|;
Thanks again. Andy

Replies are listed 'Best First'.
Re^4: Way to "trim" part of a phrase?
by BioLion (Curate) on Aug 14, 2009 at 15:02 UTC

    I can't see a difference between the two variations you posted! Also the [^chars]+[chars] was deliberate - when you define a character class, putting ^ inside negates it - so i meant 'match a string of non-special characters, followed by a special character'. i guess it could also be put as s/.*[\.\:\!\)\,]// i.e. match anything followed by a special character!

    I understand your pain about overheads and memory usage though, so keep pushing and you'll get there eventually!

    Just a something something...