473,563 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3118
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******** ******@TK2MSFTN GP15.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(Syste m.Environment.N ewLine & System.Environm ent.NewLine)
= 0


x = Replace(x, System.Environm ent.NewLine & System.Environm ent.NewLine,
System.Environm ent.NewLine)

Loop

x = Replace(x, System.Environm ent.NewLine, "</p><p>")
"Neo Geshel" <go****@geshel. org> wrote in message
news:uN******** ******@TK2MSFTN GP15.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.Replac e(..).Replace(. ..).Replace(... )

Maybe you can replace "<space><quote> " with "<space><op en 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
2790
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 I can do this with: thisString.Replace(" ", "%20") thisString.Replace("#", "%23") But, I'm trying to find a way to do this one line of code.
32
14783
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 ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
4
2437
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 replace multiple entries of an object within a string. That is, if a user hit twice to create one new line, but just once to create another, I want...
4
2479
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, three,four,,,,,,,,,,eighteen, and so on. There is one time when multiple commas are allowed. Just prior to the letters ADMNSRC there should be...
20
2530
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 based on a common ID from an ID session table. So we can have various session tables with differing results but if they contain records, they are all...
0
3070
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 want to replace all of them. You need to look at it in a case-by-case basis. What can you do? Answer: emacs.
1
1473
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 now my problem is i can do this in the textchange and keypress etc with one replace function eg . txtpass1 = Replace(txtpass, "&", "%26") ...
8
17496
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 space. What would be the most efficient way to do this? I am using SQL2K. I was thinking a function since I know of no single Transact-SQL command that...
4
1936
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 than one field or check muliple boxes to query the database. What I want to do is create a multiple search criteria data string. Below is the code that...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.