Multiple repalace

D

David

Hi,

I have a replace function <%= Replace(arData(0,i), "_", " ")%> that works
fine to replace the _ with a space, but I'd also like it to look for, and
replace one word with another in the same string (E,G replace the word
"Right" with "Wrong"). The code is located in a table that is displaying the
results of a database search.

I'm having problems with a) finding out if it's possible to do it this way,
and b) what the syntax should be. I've tried all manner of combinations, but
no luck. Any ideas?

Thanks,

David
 
E

Evertjan.

David wrote on 06 mrt 2004 in microsoft.public.inetserver.asp.general:
I have a replace function <%= Replace(arData(0,i), "_", " ")%> that
works fine to replace the _ with a space, but I'd also like it to look
for, and replace one word with another in the same string (E,G replace
the word "Right" with "Wrong"). The code is located in a table that is
displaying the results of a database search.


<% = Replace(arData(0,i), "Right", "Wrong") %>

preferably do:

<% = Replace(arData(0,i), "Wrong", "Right") %>
 
D

David

<% = Replace(arData(0,i), "Right", "Wrong") %>

But how do I get this to ALSO change "_"," " in addition to the above?

Thanks
 
E

Evertjan.

David wrote on 06 mrt 2004 in microsoft.public.inetserver.asp.general:
<% = Replace(arData(0,i), "Right", "Wrong") %>

But how do I get this to ALSO change "_"," " in addition to the above?

<% = Replace(Replace(arData(0,i), "Right", "Wrong"),"_"," ") %>
 
D

David

Thanks Evertjan - sorted!


Evertjan. said:
David wrote on 06 mrt 2004 in microsoft.public.inetserver.asp.general:


<% = Replace(Replace(arData(0,i), "Right", "Wrong"),"_"," ") %>
 
R

Rob Greene

Greetings David:

The replace function replaces words as easy as characters. See example below. This will work in a table as easy as any other string.

<HTML>
<Body>
<%
dim TheWords
TheWords = "Now is the time to change words"
Response.write( "<li>" + TheWords )
TheWords = Replace( TheWords, "time", "age" )
Response.write( "<li>" + TheWords )
%>
</Body>
</HTML>

-rwg
This is what I think, not necessarily what is accurate!

--------------------
| From: "David" <[email protected]>
| Newsgroups: microsoft.public.inetserver.asp.general
| Subject: Multiple repalace
| Lines: 17
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| X-Inktomi-Trace: spr1-pool1-5-0-cust128.cosh.broadband.ntl.com 1078563852 22352 80.5.233.128 (6 Mar 2004 09:04:12 GMT)
| Message-ID: <[email protected]>
| Date: Sat, 6 Mar 2004 09:04:44 -0000
| NNTP-Posting-Host: 80.1.224.5
| X-Complaints-To: (e-mail address removed)
| X-Trace: newsfep3-gui.server.ntli.net 1078563853 80.1.224.5 (Sat, 06 Mar 2004 09:04:13 GMT)
| NNTP-Posting-Date: Sat, 06 Mar 2004 09:04:13 GMT
| Organization: ntl News Service
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!newsfeed.wirehub.nl!
194.168.222.61.MISMATCH!newspeer1-gui.server.ntli.net!ntli.net!newsfep3-gui.server.ntli.net.POSTED!53ab2750!not-for-mail
| Xref: cpmsftngxa06.phx.gbl microsoft.public.inetserver.asp.general:267661
| X-Tomcat-NG: microsoft.public.inetserver.asp.general
|
| Hi,
|
| I have a replace function <%= Replace(arData(0,i), "_", " ")%> that works
| fine to replace the _ with a space, but I'd also like it to look for, and
| replace one word with another in the same string (E,G replace the word
| "Right" with "Wrong"). The code is located in a table that is displaying the
| results of a database search.
|
| I'm having problems with a) finding out if it's possible to do it this way,
| and b) what the syntax should be. I've tried all manner of combinations, but
| no luck. Any ideas?
|
| Thanks,
|
| David
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top