everything but a pattern regex

41 Views Asked by At

I'm trying to use a regex to extract a portion of a string.

My string looks like so: sometext[pattern]moretext[pattern]somemoretext and I want my regex to return me everything BUT the text in the pattern.

So the expected return is: sometextmoretextsomemoretext

I can match my pattern with this regex: \[[a-z]+\]/g

And I've been reading about javascript lookarounds,

so I thought I could do something like: (?!(\[[a-z]+\]))/g

But that returns something a little strange: ["", "", "" ...]

What am I doing wrong?

0

There are 0 best solutions below