I have a negative lookbehind AND a negative lookahead and so far it's ALMOST working. I have googled, I have searched stackOverflow, but can not find my exact issue. What I am trying to achieve is to capture any text within brackets AS LONG AS they are not found between my <code></code>
tags.
My regex attempt
(?<!<code>)\[(.*?)\](?!<\/code>)
Test Text
[bracket] <-- currently matches (ok)
<code>[bracket] <-- currently does NOT match (ok)
[bracket]</code> <-- currently does NOT match (ok)
<code> some text [bracket] other text </code> <-- currently matches (!!NOT OK!!)
<code>[bracket]</code> <-- currently does NOT match (ok)
I'm really having problems getting around the fact that you must have a fixed width in a negative lookbehind/negative lookahead. I've tried anything from trying to grab any character between the <code>
and the bracket, but that just grabs the <code>
tag and matches with almost all the examples above. I've tried the ^
character to try to exclude any lines with <code>
but that ended up just excluding everything. I'm at my wits end. Any direction is truly appreciated!!
foobar[bracket]`, with no `
`? Or will that not occur? – CertainPerformance Sep 01 '20 at 04:21``` tags. It needs to have both the opening and closing tag. – Anna Sep 01 '20 at 04:23
[bracket]` doesn't have closing tag and `[bracket]
` doesn't have closing tag, so these `[brackets]` **are not** inside `...
`. Why shouldn't they match? – Toto Sep 01 '20 at 09:29