Multiple repalace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David

    Multiple repalace

    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


  • Evertjan.

    #2
    Re: Multiple repalace

    David wrote on 06 mrt 2004 in microsoft.publi c.inetserver.as p.general:[color=blue]
    > 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.[/color]


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

    Comment

    • David

      #3
      Re: Multiple repalace

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

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

      Thanks




      Comment

      • Evertjan.

        #4
        Re: Multiple repalace

        David wrote on 06 mrt 2004 in microsoft.publi c.inetserver.as p.general:
        [color=blue]
        > <% = Replace(arData( 0,i), "Right", "Wrong") %>
        >
        > But how do I get this to ALSO change "_"," " in addition to the above?
        >[/color]

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

        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • David

          #5
          Re: Multiple repalace

          Thanks Evertjan - sorted!


          "Evertjan." <exjxw.hannivoo rt@interxnl.net > wrote in message
          news:Xns94A4746 654A9Eeejj99@19 4.109.133.29...[color=blue]
          > David wrote on 06 mrt 2004 in microsoft.publi c.inetserver.as p.general:
          >[color=green]
          > > <% = Replace(arData( 0,i), "Right", "Wrong") %>
          > >
          > > But how do I get this to ALSO change "_"," " in addition to the above?
          > >[/color]
          >
          > <% = Replace(Replace (arData(0,i), "Right", "Wrong"),"_ "," ") %>
          >
          > --
          > Evertjan.
          > The Netherlands.
          > (Please change the x'es to dots in my emailaddress)[/color]


          Comment

          • Rob Greene

            #6
            RE: Multiple repalace

            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" <david@brown666 9.freeserve.co. uk>
            | Newsgroups: microsoft.publi c.inetserver.as p.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.br oadband.ntl.com 1078563852 22352 80.5.233.128 (6 Mar 2004 09:04:12 GMT)
            | Message-ID: <hug2c.30$I46.6 @newsfep3-gui.server.ntli .net>
            | Date: Sat, 6 Mar 2004 09:04:44 -0000
            | NNTP-Posting-Host: 80.1.224.5
            | X-Complaints-To: abuse@ntlworld. com
            | 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.ph x.gbl!TK2MSFTNG P08.phx.gbl!new sfeed00.sul.t-online.de!t-online.de!newsf eed.wirehub.nl!
            194.168.222.61. MISMATCH!newspe er1-gui.server.ntli .net!ntli.net!n ewsfep3-gui.server.ntli .net.POSTED!53a b2750!not-for-mail
            | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.inetserver.as p.general:26766 1
            | X-Tomcat-NG: microsoft.publi c.inetserver.as p.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
            |
            |
            |


            Comment

            Working...