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:[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 (

    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: "$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 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):*sdfr.sdsf

Any ideas about this problem? I’ve tried with many alternatives with no luck, but it seems the solution should be easy.

My current working pattern in hyperlink.cson is as follows:

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

It recognizes URLs such as,, etc., but not[param]showResults?code=343 or*sdref.dee. I tried modifying the regular expression to recognize […] and * as part of a URL, but with no luck.