473,382 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

selective replacements

I have this in one of my scripts to take out line breaks:
$html=str_replace(array("\n","\r"),"",$html);

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 ?
Nov 11 '05 #1
1 1091
it will be a big regex if you want to finish the job with only one reg
expression

i used this method :

1.replace the '\n' i want to keep with a strange char such as \0x23 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(\0x23) back to '\n'

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

hope help
Regards
vizo

meltedown wrote:
I have this in one of my scripts to take out line breaks:
$html=str_replace(array("\n","\r"),"",$html);

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 ?

Nov 11 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mike Connor | last post by:
I am having trouble getting Conditional Folder creation & File insertion to work using VS .Net in a Deployment Project for a C# app. I am displaying a generic Textbox Dialog under the User...
4
by: Jon Glazer | last post by:
I have a small function that simply swaps image A with image B. The problem is that in some situations (i don't know why yet) when A and B are swapped, they simply vanish. Here is the function...
2
by: Sally B. | last post by:
Hi, Using string.replace with regular expressions, is there any way to count the number of replacements that actually happens? I know you can limit the number of replacements w/ a count value, but...
1
by: Solitus | last post by:
I have databinding problem with a repeater <ItemTemplate> <tr> <!-- fixed content --> </tr> <tr> <!-- optional content --> </tr> </ItemTemplate>
4
by: John A Grandy | last post by:
IsNumeric() and IsDate() are "leftovers" from the VB6 days ... looking forward, perhaps it would be better not to use them .... does anyone have suggestions on replacements ?
4
by: alex.hatzisavas | last post by:
Dear all, I'm trying to do a selective deletion from an 'Archive' table based on dates. Here is the setup: Table 'Archive' has a date field ( ). Another table ('Cutoffs') defines the Low...
1
by: aman909 | last post by:
Hello, I have a stock control system for fabric that is produced. The stock control has contains details of every colour of fabric that is produced. We have about 40 to 50 different colours. Im...
0
by: arindams | last post by:
I've a form where an webrowser contains a html file. I want to copy a selective portion of the html content and paste that content in an excel 2007 file where it will be pasted as a normal text (not...
3
by: ThatsIT.net.au | last post by:
I have been looking into web config file section replacements I have set it buy putting in the line into the deploy section connectionStrings=connectionStrings.config; I then have a file by that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.