Regex lookbehind

I’m trying to create a regex that uses a negative lookbehind. For example this would match a string that DOES NOT star with BLAH:
/(?<!BLAH)(*.)/

I keep getting « invalid regex: invalid group spécifier name »

From initial investigation it seems that the « lookbehind » pattern, while legal in JavaScript, is not yet implemented in WebKit, hence doesn’t work on iOS?

Can someone shed some light? And maybe suggest alternatives?
Thanks.

1 Like

I haven’t checked in a while, but I believe that is correct that JavaScriptCore still does not support negative lookbehind.

There are a variety of ways to accomplish what you want without it, but it might be helpful if you have a concrete example of the text you are trying to manipulate and outcome you want to acheive to suggest an alternative.

I was investigating how to match the url htttp://some.random.url
except if it’s part of a markdown link:
[what an awesome site](htttp://some.random.url)

As a first approximation, I wanted to prefix the convoluted regex I use with:
(?<!\]\()
as in: match the url EXCEPT if it’s prefixed by ‘](`
which I thought would be good enough for my use case (expanding the scope of this action by excluding already well formed links