sommeguyy sommeguyy - 1 year ago 67
Javascript Question

how to not select lookbehind word in javascript regex

My regex: <br>![a-z]+(?=<br>)


I am trying to get word that begins with
, like
and exists between
tags. But when i apply this
, i get
I just need to select
.I mean i don't need to select first

So what is wrong with my regex?

Answer Source

Since JS does not support LookBehind, You could use groups to exclude the first <br>

var String = "fooword1<br>!fooword2<br>fooword3";
var Regexp = /<br>(![a-z]+\d)<br>/g;
var match = Regexp.exec(String);

Another option will be using Positive Lookahead at the end with <br>, and relying on the ! at the beginning:



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download