JS Regex to find href of several a tags

后端 未结 9 1144
野性不改
野性不改 2020-12-28 08:04

I need a regex to find the contents of the hrefs from these a tags :

9条回答
  •  隐瞒了意图╮
    2020-12-28 08:52

    I combined a few solutions around and came up with this (Tested in .NET):

    (?<=href=[\'\"])([^\'\"]+)
    

    Explanation:

    (?<=) : look behind so it wont include these characters

    [\'\"] : match both single and double quote

    [^] : match everything else except the characters after '^' in here

    + : one or more occurrence of last character.

    This works well and is not greedy with the quote as it would stop matching the moment it finds a quote

提交回复
热议问题