473,403 Members | 2,222 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,403 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 21 '05 #1
4 2433
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 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(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 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.Replace(..).Replace(...).Replace(...)

Maybe you can replace "<space><quote>" with "<space><open 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
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...
58
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...
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: 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
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?
0
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...
0
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.