I'm trying to figure out the correct regex to do this in javascript. In pcre, this does exactly what I want:
/^.*(?<!\/)kb([0-9]+).*$/im
Goal:
- If I have a value that isn't prefixed with a forward-slash, e.g KB12345, it'll match the number within.
- If that value is prefixed with a forward-slash it won't match, e.g: http://someurl.com/info/KB12345
However it looks like while this works in pcre, it won't work in javascript due to the syntax of the negation:
(?<!\/)
I've been trying to figure this out in regex101 but no luck yet. Any ideas or suggestions on what the pure-regex equivalent in javascript is?
I saw there's a negative look-ahead, but I can't seem to figure it out:
/^.*(?!\/KB)kb([0-9]+).*$/im