473,698 Members | 2,076 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 21 '05 #1
4 2441
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 21 '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 21 '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 21 '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 21 '05 #5

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

Similar topics

2
2798
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
14852
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
3123
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 both types ( & twice to create a new line (by creating a blank line between paragraphs). ...
4
2481
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 one instance of 4 commas. ( ,eight,,,,ADMNSRC,thirteen, ). The text ADMNSRC is NOT in the same
20
2557
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 keyed to the common ID. My problem now however is how do I report the overall findings of the
0
3077
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
1483
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") works no probs ... however there are multiple instances i need to change if they are present in txtpass...
8
17510
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 can accomplish this task.
4
1946
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 working with a the moment. Any input would be appreciate. Thanks Greg If...
58
8085
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also the parts section an i seem to be having trouble. When i try to insert into the parts section i get the error Invalid character value for cast specification. But not sure what i am doing wrong. Here is what i am using to insert. All the sections...
0
8603
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9023
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8861
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7721
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4366
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3045
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
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.