Regex in Javascript to remove links

后端 未结 6 1731
南旧
南旧 2020-12-06 17:22

I have a string in JavaScript and it includes an a tag with an href. I want to remove all links and the text. I know how to just r

6条回答
  •  爱一瞬间的悲伤
    2020-12-06 17:26

    This will strip out everything between and /a>:

    mystr = "check this out Click me. cool, huh?";
    alert(mystr.replace(/]*>(.*?)<\/a>/i,""));
    

    It's not really foolproof, but maybe it'll do the trick for your purpose...

提交回复
热议问题