Text Replace function

Discussion in 'ASP General' started by Mark Tait, Jul 3, 2003.

  1. Mark Tait

    Mark Tait Guest

    Hi - I'm using the replace function to hilite search words in text which
    is returned. However, as the text which is being searched also includes
    HTML, I find sometimes that the HTML tags can be replaced, which in turn
    messes up the text which is dieplayed.

    Is there any way of checking only text which does not appear between <>
    tags?

    eg.

    myText="<img src='bob.gif'>bob"
    mySearch="bob"

    replace(myText,mySearch,"<b>" & mySearch & "</b>")

    ...this will end up:

    myText="<img src='<b>bob</b>.gif'><b>bob</b>"

    Has anyone any ideas?

    Many thanks,


    Mark Tait

    www.fixitks.co.uk
    Knowledge Management Solutions

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Mark Tait, Jul 3, 2003
    #1
    1. Advertising

  2. Mark Tait

    Evertjan. Guest

    Mark Tait wrote on 03 jul 2003 in
    microsoft.public.inetserver.asp.general:

    > Hi - I'm using the replace function to hilite search words in text
    > which is returned. However, as the text which is being searched also
    > includes HTML, I find sometimes that the HTML tags can be replaced,
    > which in turn messes up the text which is dieplayed.
    >
    > Is there any way of checking only text which does not appear between
    > <> tags?
    >
    > eg.
    >
    > myText="<img src='bob.gif'>bob"
    > mySearch="bob"
    >
    > replace(myText,mySearch,"<b>" & mySearch & "</b>")
    >
    > ..this will end up:
    >
    > myText="<img src='<b>bob</b>.gif'><b>bob</b>"
    >
    > Has anyone any ideas?
    >


    This replace is not a good idea.

    do something with:

    txt.select();

    like in:

    <http://www.javascripter.net/faq/searchin.htm>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jul 3, 2003
    #2
    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. juglesh
    Replies:
    16
    Views:
    344
    juglesh
    Dec 27, 2004
  2. penny
    Replies:
    28
    Views:
    3,054
    Charlton Wilbur
    Mar 10, 2008
  3. mscir
    Replies:
    0
    Views:
    332
    mscir
    Oct 12, 2005
  4. Replies:
    7
    Views:
    208
    Yanick
    Aug 4, 2006
  5. V S Rawat
    Replies:
    5
    Views:
    345
    Richard Cornford
    Jul 3, 2007
Loading...

Share This Page