I’m making a bot which gives full links for wikilinks like [[Foo]] given on IRC. What I want to do is to have ‘[[foo]]’, ‘before [[foo]], ‘[[foo]] after’ and ‘before [[foo]] after’ match, but not ‘`[[foo]]’, ‘before `[[foo]]’, etc., ‘`’ being a sort of “escape” character in the program. So far I got
/[^`]\[\[(.+)\]\]/
However, that doesn’t match “[[foo]]”. If I add a ? after the negated character class, it defeats its purpose and all the backticked links still match.
How could I do this?
P.S. I want to have a single regex.
Just add the beginning of the line as an alternative to “a character that is not
`“: