Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore First Character in Regex Match

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

My regular expression:

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

Matches the following:

enter image description here

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

Here is the regular expression on regexr.com.

like image 561
Matthew Avatar asked Jun 30 '14 20:06

Matthew


2 Answers

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.

like image 91
Jerry Avatar answered Nov 13 '22 08:11

Jerry


You can use:

.*?>(\w+)<

Regular expression visualization

Here you can check a working example:

Debuggex Demo

like image 35
Federico Piazza Avatar answered Nov 13 '22 07:11

Federico Piazza