admin管理员组

文章数量:1202598

I need to ignore the > in my regular expression in the beginning.

My regular expression:

/(>(.+)(?=<\/a>))/igm

Matches the following:

How do I tell it to ignore the > in the beginning?

Here is the regular expression on regexr.

I need to ignore the > in my regular expression in the beginning.

My regular expression:

/(>(.+)(?=<\/a>))/igm

Matches the following:

How do I tell it to ignore the > in the beginning?

Here is the regular expression on regexr.com.

Share Improve this question edited Aug 16, 2019 at 18:32 Asad Shakeel 2,2851 gold badge25 silver badges30 bronze badges asked Jun 30, 2014 at 20:43 MatthewMatthew 2,2468 gold badges32 silver badges54 bronze badges 3
  • positive lookbehind, though it doesnt work in regexr.com for some reason. – Ed Morales Commented Jun 30, 2014 at 20:46
  • 1 @EdwardM.B.: the reason is that the lookbehind feature isn't available in Javascript. – Casimir et Hippolyte Commented Jun 30, 2014 at 20:48
  • stackoverflow.com/questions/590747/… – epascarello Commented Jun 30, 2014 at 20:49
Add a comment  | 

2 Answers 2

Reset to default 12

Possible workaround would be to match non > characters:

[^>]+(?=<\/a>)

regex101 demo

Or you take the substring of each of your results in the code itself.

You can use:

.*?>(\w+)<

Here you can check a working example:

Debuggex Demo

本文标签: javascriptIgnore First Character in Regex MatchStack Overflow