Jump to content

Preserving Hard-Returns In A Bunch Of Text


Johnny2

Recommended Posts

I am trying to copy a bunch of text which consists of several different paragraphs (with empty space in between them).

 

Then I would like to paste this text into a form's textarea field.

 

When I submit the form I would like to clean the information with something like the preg_replace below.

 

$cleaned_info = preg_replace('#[^A-Za-z0-9)(,\'\.\-!?$" "" "]#i', '', $_POST['info']);

 

How do I preserve the empty lines between paragraphs (which I'm assuming are hard-returns or whatever)?

 

Adding \n to the things which I would like to preserve didn't work.

Edited by Johnny2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...