SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Mar 2006
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need RegEx Help...

    Hello all,
    I am quite new to using regular expressions in javascript.
    here is what i am trying to do.For a given string, i want to replace all hyperlinks contained within the string with the innerHTML of the link.

    For example,I have this string..
    Code:
    <script language='javascript'>
           var str = 'This is a normal text. this is  a <a href="javascript:void(0);">Link(Click me)</a>.<br/>This is another <a href="http://www.google.com">link</a>';
        
        </script>
    using regex , i want to remove these hyperlinks such that the resulting output would be "This is a normal text.this is a Link(Click me).<br />This is another link"

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    Code:
    /<a.*?>|<\/a>/gi


Bookmarks

Posting Permissions

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