I have a regex created by myself that I am currently running in PHP. Although when I merge it over to JavaScript, it refuses to work. I have also tried it in Python and it works perfectly fine.
Regex:
@[[](.[^]]+)[]][()](\d+)[)]
I have a regex created by myself that I am currently running in PHP. Although when I merge it over to JavaScript, it refuses to work. I have also tried it in Python and it works perfectly fine.
Regex:
@[[](.[^]]+)[]][()](\d+)[)]
JavaScript doesn't automatically escape your ].
This will help you get a visual idea:



So to fix this, you need to escape the brackets
@[[](.[^\]]+)[\]][()](\d+)[)]
// ^ ^
The best way to write this regex is to minimize the use of character classes:
@\[(.[^\]]+)\][()](\d+)\)
That's why it's good practice to escape this stuff instead of relying on quirks of the flavor.
I generated these images through regex101.
[\]] different from just \]?@\[(.[^\]]+)\][()](\d+)\).
@[]User Name])1234). It seems like an odd rule for any practical purpose.@[User Name](1234). It is for a tagging system I have created so that I can convert that into a link to a users profile based on their ID by displaying their username..and the second)doesn't really make any sense in that context.