Multiple repalace

Discussion in 'ASP General' started by David, Mar 6, 2004.

  1. David

    David Guest

    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
    David, Mar 6, 2004
    #1
    1. Advertising

  2. David

    Evertjan. Guest

    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") %>


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Mar 6, 2004
    #2
    1. Advertising

  3. David

    David Guest

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

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

    Thanks
    David, Mar 6, 2004
    #3
  4. David

    Evertjan. Guest

    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"),"_"," ") %>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan., Mar 6, 2004
    #4
  5. David

    David Guest

    Thanks Evertjan - sorted!


    "Evertjan." <> wrote in message
    news:Xns94A4746654A9Eeejj99@194.109.133.29...
    > 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"),"_"," ") %>
    >
    > --
    > Evertjan.
    > The Netherlands.
    > (Please change the x'es to dots in my emailaddress)
    David, Mar 6, 2004
    #5
  6. David

    Rob Greene Guest

    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" <>
    | 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: <hug2c.30$>
    | Date: Sat, 6 Mar 2004 09:04:44 -0000
    | NNTP-Posting-Host: 80.1.224.5
    | X-Complaints-To:
    | 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
    |
    |
    |
    Rob Greene, Mar 7, 2004
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stephen Miller
    Replies:
    0
    Views:
    1,638
    Stephen Miller
    Jun 24, 2003
  2. Andrew Kidd
    Replies:
    3
    Views:
    468
    Andrew Kidd
    Apr 22, 2004
  3. Diane Selby
    Replies:
    4
    Views:
    6,769
  4. tshad
    Replies:
    2
    Views:
    464
    tshad
    Jan 27, 2005
  5. Schultz
    Replies:
    1
    Views:
    504
    Karl Seguin
    Feb 14, 2005
Loading...

Share This Page