Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clean up Text

Status
Not open for further replies.

bnc123

Technical User
Mar 25, 2001
59
AU
I have copied some text from a webpage and used it in a form texarea. This text gets saved as data. The text as copied looks like this:

---------------
The Mercure Inn Continental Broome is located 1km from the heart of Broome
and a short 10 minute drive from Cable Beach, set in tropical landscaped
gardens making it the perfect location for relaxation or adventure.
---------------

There are line breaks due to the width of the paragraph on that webpage.

I then recall the data on a webpage within a javascript. But since there are line breaks, the javascript does not work.

I have tried:
$description =~ s/\n/<br>/g; and
$description =~ s/\n//g;

But still no joy.

Is there any way of getting the copied text into one line only? Sort of like cleaning or tidying up the text.
 
try a combination with \n (newline) , \r (return) and \f (form feed). As I remember it should be something with:

s/\n/\n\r/g;
 
Thanks uida1154, I tried a combination and it worked. Have a nice day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top