Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Remove newlines from string

Posted on 1998-11-19
3
Medium Priority
?
821 Views
Last Modified: 2008-03-03
How can I remove all newlines from a string?
ie:
$a = "whatever including newlines";
$a =~ /whatever without newlines/;
0
Comment
Question by:Lee5
  • 2
3 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 200 total points
ID: 1206368
  chop $a;
or
   chomp $a;
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1206369
oops, if they are not at end of string:

   $a =~ s/[\r\n]+//;

0
 

Author Comment

by:Lee5
ID: 1206370
The oops did the trick
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question