CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Removing \n in each line and make the content in a single line

 



pckanth
New User

Jul 19, 2007, 4:58 AM

Post #1 of 2 (1920 views)
Removing \n in each line and make the content in a single line Can't Post

Hi,

When i enter a 4 lines in a text box and submit the form.The content goes into text file.

Input:
This
is
Problem to
fix

The text file contains:

This<BR> \n
is <BR> \n
Problem to <BR> \n
fix <BR> \n

But I need like:
This <BR> is <BR> Problem to <BR> fix <BR>.

What i need is removing of newlines and all 4 lines in a single line.

Advance thanks.

Frown


KevinR
Veteran


Jul 19, 2007, 9:04 AM

Post #2 of 2 (1919 views)
Re: [pckanth] Removing \n in each line and make the content in a single line [In reply to] Can't Post

try:


Code
$input =~ /[\r\n]//g;


where $input is the data recieved from the textarea form field.

[\r\n] is a character class of carraige returns and newlines. The "g" modifier tells the regexp to find them all, and replacement pattern is blank so it removes them all.
-------------------------------------------------

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives