Re: Using s///g to remove carriage returns



Jason wrote:
I've gone through about a dozen options, and none of them work
correctly! This is driving me nuts.

The request is pretty simple: I have a form with a textarea field, and
I want to remove any opening or trailing carriage returns from it
(while leaving any return in the middle). This is the code I tried most
recently, and was certain would work:

$comment =~ s/^\r\n+|^\r+|^\n+|\r\n+$|\r+$|\n+$//g;

But, it doesn't seem to have any impact at all! Correct me if I'm
wrong, but I thought that this broke down like:

Do you guys see what I'm overlooking?

In a nutshell: the precedence of operators (concatenation is an operator) in regular expressions.

--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

.



Relevant Pages

  • Re: WQMA
    ... He played a request before the show ... PS Don't forget to donate - looks like Jason and the guys need the cash ... I got out of the habit of listening to the FF back in the dim and distant days when I used to download the show from Wayne Ross' site. ... Besides which, the FF contains the same tracks too often (well, yes, I *know* they're the most popular tracks, that's why they're there, but you can end up chasing your tail that way). ...
    (rec.music.dementia)
  • Re: hhkjdkkkdsehyuwe
    ... When people invoke God for their political purposes, ... It is a request for comfort, courage and strength in the wake of the tragedy. ... It is not a request for Divine intervention in the actions associated with it. ... The nuts don't know they're nuts. ...
    (misc.transport.road)
  • Re: WQMA
    ... Alas, I had a hardware failure and my recording ended up dying ... He played a request before the show started, but I don't know what happened after the end of the main segment, 'cos I never listen to the Funny Five). ... PS Don't forget to donate - looks like Jason and the guys need the cash just now. ...
    (rec.music.dementia)
  • Re: Bipedalism in different substrates
    ... which I feel is a reasonable request. ... If Jason really wished ... > to ignore Algis, he wouldn't bother to reply at all. ... they pass under that quite low threshold, they just dont get in my killfile. ...
    (sci.anthropology.paleo)
  • Re: Using declaritive security on class members
    ... I just tried that on your recommendation and I get the ... same rejection. ... Request for Principal Permission Failed. ... Jason ...
    (microsoft.public.dotnet.security)