Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

using replace method with matches

Last post 04-19-2011, 7:23 PM by Aussie Susan. 1 replies.
Sort Posts: Previous Next
  •  04-19-2011, 2:58 PM 80978

    using replace method with matches

    hi there.  i want to use regular expressions to find certain text, and then replace this text with a new value THAT INCLUDES THE original match.

    for example:  i have html that has the word "OBJ=123" and i want to find and replace all instances with "<A HREF=asdfasd>OBJ=123</a>"

    can anyone tell me how to do this?  I'm using classic ASP...

  •  04-19-2011, 7:23 PM 80989 in reply to 80978

    Re: using replace method with matches

    Normally, I would recommend using the HTML DOM to do this type of thing as it handles all of the weird things that can occur within 'valid" HTML files.

    Also, I assume that you are looking for the exact character sequence "OBJ=123" and that this is not just an example of a string that you want to find, but have not specified.

    Given that, try a pattern of

    OBJ=123

    and a replacement string of

    <A href=asdfasd>$0</a>

    (For some reason, the forum software if replacing my uppercase HREF with a lowercase version in the above line)

    However, please be aware that this will ONLY find "OBJ=123" and will add in exactly the replacement string with the "OBJ=123" added into it.

    Susan

View as RSS news feed in XML