Recognizing square brackets in hyperlinks (TextMate grammar)

I need to recognize URLs including also square brackets (as I have real URLs with square brackets), like:

http://ThisIsAnExample.com/query[conpub]showResults?code=343
(this is a made-up example, similar to a real one)

I tried multiple options, including the simple option of adding in the same way as () is added in the solution proposed at https://github.com/atom/language-hyperlink/pull/13/files (https://github.com/atom/language-hyperlink/pull/13):

    match: "(?x)\\b(https?|thunderlink|cbthunderlink|imap-message|mailbox-message|s?ftp|ftps|file|smb|afp|nfs|(?:x-)?man(?:-page)?|gopher|txmt|issue)://((?!(\\#[[:word:]]*\\#))(?:[-:@[:word:].~%$+_/?=&#;|!()[]]))+(?<![-.,?:#;])"
    name: "markup.underline.link.$1.hyperlink"

But there is no way to make it work. I tried many other options (including regular expressions with OR |, using escape characters, etc.). Should this work? Is it possible to define this?

I have also noticed a strange thing: even if I try the original expression in a regular expression tester like the one available at https://regex101.com/ I obtain errors (even though the original expression works in Atom).

Any idea would be welcome.

Markdown format uses square brackets notation for hyperlinks.
Write file with .mdextension and preview in markdown-preview-enhanced.

Correction: On second read I see that you require to use square brackets inside a URL string. Can you use encoding?

A quick google search found one article.
%5B and %5D

I’m not sure about how I can use the encoding suggested in my previous regular expression. I tried with no luck.

I’m also finding problems to recognize URLs with a star, like (made up URL, similar to a real existing one):

https://www.examplewebsite.com/1*sdfr.sdsf