473,396 Members | 1,892 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,396 software developers and data experts.

Multiple .replace() in asp.net/vb.net

Greetings

I am using VB in my ASP.NET project that uses an admin web site to
populate a database that provides content for a front end web site. I am
looking for a way to use replace() to replace multiple entries of an
object within a string. That is, if a user hit [enter] twice to create
one new line, but [enter] just once to create another, I want both types
([vbcrlf vbcrlf] & [vbcrlf}) replaced by </p><p>.

The reason is this: I don't want to strip out multiple vbcrlf's at the
admin site/database, because the users are used to hitting [enter] twice
to create a new line (by creating a blank line between paragraphs).
However, when the content is displayed on the front end site, I need to
replace *any number* of sequential vbcrlf's (from just a single one, to
multiple ones of any number) with a single </p>vbcrlf[tab character]<p>
(the data will be dumped inside a single paragraph: <p>[data]</p>, so
this replacement of vbcrlf will break up the data into multiple paragraphs).

I am also curious as to how to string multiple replace()'s together.
That is, I want to convert regular quotes to curly quotes. I want to
replace one kind of single quote "text -> “text and then within the same
string also replace another kind of single quote text" -> text”. I am
sure that the replace() was built to have multiple expressions within
the bracket, but I can't seem to find any info on that.

And finally, any info on how to explicitly set certain special
characters, like tabs and spaces (much like how vbcrlf creates a return)
would be appreciated.

TIA
...Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************
Nov 19 '05 #1
4 3105
You should look into learning about the RegEx class. It's daunting at
first, but it will allow you to create replacements that you need easily.
--
Michael Earls
The Cerebral Kitchen
http://www.cerkit.com/
"Neo Geshel" <go****@geshel.org> wrote in message
news:uN**************@TK2MSFTNGP15.phx.gbl...
Greetings

I am using VB in my ASP.NET project that uses an admin web site to
populate a database that provides content for a front end web site. I am
looking for a way to use replace() to replace multiple entries of an
object within a string. That is, if a user hit [enter] twice to create
one new line, but [enter] just once to create another, I want both types
([vbcrlf vbcrlf] & [vbcrlf}) replaced by </p><p>.

The reason is this: I don't want to strip out multiple vbcrlf's at the
admin site/database, because the users are used to hitting [enter] twice
to create a new line (by creating a blank line between paragraphs).
However, when the content is displayed on the front end site, I need to
replace *any number* of sequential vbcrlf's (from just a single one, to
multiple ones of any number) with a single </p>vbcrlf[tab character]<p>
(the data will be dumped inside a single paragraph: <p>[data]</p>, so
this replacement of vbcrlf will break up the data into multiple paragraphs).

I am also curious as to how to string multiple replace()'s together.
That is, I want to convert regular quotes to curly quotes. I want to
replace one kind of single quote "text -> "text and then within the same
string also replace another kind of single quote text" -> text". I am
sure that the replace() was built to have multiple expressions within
the bracket, but I can't seem to find any info on that.

And finally, any info on how to explicitly set certain special
characters, like tabs and spaces (much like how vbcrlf creates a return)
would be appreciated.

TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************
Nov 19 '05 #2
replace all double VBCRLFs with single ones repeatedly until there are no
double VBCRLFs left, then do your replace.

Dim x As String

Do While x.IndexOf(System.Environment.NewLine & System.Environment.NewLine)
= 0


x = Replace(x, System.Environment.NewLine & System.Environment.NewLine,
System.Environment.NewLine)

Loop

x = Replace(x, System.Environment.NewLine, "</p><p>")
"Neo Geshel" <go****@geshel.org> wrote in message
news:uN**************@TK2MSFTNGP15.phx.gbl...
Greetings

I am using VB in my ASP.NET project that uses an admin web site to
populate a database that provides content for a front end web site. I am
looking for a way to use replace() to replace multiple entries of an
object within a string. That is, if a user hit [enter] twice to create
one new line, but [enter] just once to create another, I want both types
([vbcrlf vbcrlf] & [vbcrlf}) replaced by </p><p>.

The reason is this: I don't want to strip out multiple vbcrlf's at the
admin site/database, because the users are used to hitting [enter] twice
to create a new line (by creating a blank line between paragraphs).
However, when the content is displayed on the front end site, I need to
replace *any number* of sequential vbcrlf's (from just a single one, to
multiple ones of any number) with a single </p>vbcrlf[tab character]<p>
(the data will be dumped inside a single paragraph: <p>[data]</p>, so
this replacement of vbcrlf will break up the data into multiple paragraphs).

I am also curious as to how to string multiple replace()'s together.
That is, I want to convert regular quotes to curly quotes. I want to
replace one kind of single quote "text -> "text and then within the same
string also replace another kind of single quote text" -> text". I am
sure that the replace() was built to have multiple expressions within
the bracket, but I can't seem to find any info on that.

And finally, any info on how to explicitly set certain special
characters, like tabs and spaces (much like how vbcrlf creates a return)
would be appreciated.

TIA
....Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************
Nov 19 '05 #3
Neo Geshel wrote:
Greetings
I am also curious as to how to string multiple replace()'s together.
That is, I want to convert regular quotes to curly quotes. I want to
replace one kind of single quote "text -> "text and then within the
same string also replace another kind of single quote text" -> text".
I am sure that the replace() was built to have multiple expressions within
the bracket, but I can't seem to find any info on that.
TIA
...Geshel


You can't write multiple replacements with a single bracket-pair,
but you can use something like
myString = myString.Replace(..).Replace(...).Replace(...)

Maybe you can replace "<space><quote>" with "<space><open curly quote>"
and so on.

Hans Kesting
Nov 19 '05 #4
Use Regex to replace. You can set up Regex with a pattern that replaces one,
or more, instances of \r\n with </p><p>. It would be far more costly to have
it loop until all \r\n were replaced.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Neo Geshel" wrote:
Greetings

I am using VB in my ASP.NET project that uses an admin web site to
populate a database that provides content for a front end web site. I am
looking for a way to use replace() to replace multiple entries of an
object within a string. That is, if a user hit [enter] twice to create
one new line, but [enter] just once to create another, I want both types
([vbcrlf vbcrlf] & [vbcrlf}) replaced by </p><p>.

The reason is this: I don't want to strip out multiple vbcrlf's at the
admin site/database, because the users are used to hitting [enter] twice
to create a new line (by creating a blank line between paragraphs).
However, when the content is displayed on the front end site, I need to
replace *any number* of sequential vbcrlf's (from just a single one, to
multiple ones of any number) with a single </p>vbcrlf[tab character]<p>
(the data will be dumped inside a single paragraph: <p>[data]</p>, so
this replacement of vbcrlf will break up the data into multiple paragraphs).

I am also curious as to how to string multiple replace()'s together.
That is, I want to convert regular quotes to curly quotes. I want to
replace one kind of single quote "text -> “text and then within the same
string also replace another kind of single quote text" -> text”. I am
sure that the replace() was built to have multiple expressions within
the bracket, but I can't seem to find any info on that.

And finally, any info on how to explicitly set certain special
characters, like tabs and spaces (much like how vbcrlf creates a return)
would be appreciated.

TIA
...Geshel
--
************************************************** ********************
My reply-to is an automatically monitored spam honeypot. Do not use it
unless you want to be blacklisted by SpamCop. Please reply to my first
name at my last name dot org.
************************************************** ********************

Nov 19 '05 #5

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

Similar topics

2
by: JS | last post by:
Is it possible to do multiple replaces in a string? Example: I'm trying to replace all of the spaces with "%20" and "#" with "%23", etc. I also need to replace the "?", "!", " ' ", etc. I know...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
4
by: Neo Geshel | last post by:
Greetings I am using VB in my ASP.NET project that uses an admin web site to populate a database that provides content for a front end web site. I am looking for a way to use replace() to...
4
by: striker | last post by:
I have a comma delimited text file that has multiple instances of multiple commas. Each file will contain approximatley 300 lines. For example: one, two, three,,,,four,five,,,,six one, two,...
20
by: p175 | last post by:
Hi people, I have a stored procedure that creates many Global temporary session tables. Into each of these tables go the results of various processing using relational division all keyed and...
0
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not...
1
by: vbisjustforme | last post by:
sup guys, hit a mental snag an need some help. i want to search a defined string (textbox), and replace all characters in that string to Hex(KeyAscii) with "%" in front of the Hex(KeyAscii) right...
8
by: Joe Cool | last post by:
I need to map several columns of data from one database to another where the data contains multiple spaces (once occurance of a variable number or spaces) that I need to replace with a single...
4
by: gblack301 | last post by:
Hi, I have a search form where the user can check a box or enter some data such as a name to quey the database. I was wondering what is the best way to enable the ability for a user data in more...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.