Multiple .replace() in asp.net/vb.net  
Author Message
reshugoyal





PostPosted: Thu Jun 16 07:24:05 CDT 2005 Top

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

Greetings

I am using VB in my ASP.NET project that uses an admin web site to=20
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=20
object within a string. That is, if a user hit [enter] twice to create=20
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=20
admin site/database, because the users are used to hitting [enter] twice =

to create a new line (by creating a blank line between paragraphs).=20
However, when the content is displayed on the front end site, I need to=20
replace *any number* of sequential vbcrlf's (from just a single one, to=20
multiple ones of any number) with a single </p>vbcrlf[tab character]<p>=20
(the data will be dumped inside a single paragraph: <p>[data]</p>, so=20
this replacement of vbcrlf will break up the data into multiple paragraph=
s).

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

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

would be appreciated.

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

DotNet42  
 
 
Michael





PostPosted: Thu Jun 16 07:24:05 CDT 2005 Top

ADO >> Multiple .replace() in asp.net/vb.net 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/




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.
**********************************************************************


 
 
Rick





PostPosted: Thu Jun 16 09:38:01 CDT 2005 Top

ADO >> Multiple .replace() in asp.net/vb.net 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>")




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.
**********************************************************************


 
 
Hans





PostPosted: Thu Jun 16 10:50:10 CDT 2005 Top

ADO >> Multiple .replace() in asp.net/vb.net
> 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


 
 
NoSpamMgbworld





PostPosted: Thu Jun 16 15:17:02 CDT 2005 Top

ADO >> Multiple .replace() in asp.net/vb.net 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!
***************************




> 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.
> **********************************************************************
>