selective replacements

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have this in one of my scripts to take out line breaks:

Now I would like to leave some line breaks.
For example, if $html has something like this:
"<textarea> default text\n with line \nbreaks </textarea>"
I would like to leave all the linebreaks between the <textarea> tags.
Does any one know of a script, or a  regular expression that can do this ?

Re: selective replacements

it will be a big regex if you want to finish the job with only one reg  

i used this method :

1.replace the '\n' i want to keep with a strange char such as x23 one  
by one
    thus,the regex is easy to access

2.after replaced all '\n's  should be kept, use '\r' to take place of  
'\n' left
    the '\n' left is really what you want to replace

3.turn our strange char(x23) back to '\n'

your should make several easy reg expressions,
but not a big big one.

hope help


meltedown wrote:
Quoted text here. Click to load it

Site Timeline