Text Replace function

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Text Replace function

    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
    [email]mark@fixitks.co.uk[/email]
    [url]www.fixitks.co.uk[/url]
    Knowledge Management Solutions

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Mark Tait Guest

  2. Similar Questions and Discussions

    1. Replace function
      Please help, I want to replace a string within field in a table with a nother string. I am using the replace function but I am doing something...
    2. Trouble using Replace() function in CFN file
      I don't do much scripting in coldfusion besides some of the very basics for trasfering info from the database, so I'm not sure how to write this.......
    3. Problem with VB replace function for CRLF...I think
      I'm not sure if this is the best place for this post, sorry if it is not... Here is what I am doing: I have created a small kbase (SQL db)...
    4. Search & Replace Function?
      I have some textfield that users will enter data into on my web site and then I'll use php and write it to mysql - for security purposes, is there...
    5. Using Replace function to remove two different characters
      I'm using replace function to strip 0s from a particular string: <%=replace(rs1("racelength"),"0","''"%> but I need to also strip empty spaces...
  3. #2

    Default Re: Text Replace function

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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139