Subject: Regex library doesn't recognize ']' in a character class

From: Abdulrahman Semrie <[email-masked]>
Date: Sun, 16 Jun 2019 20:16:29 +0300

I am using the pattern [\\[\\]a-zA-Z]+ to match a string with left or right bracket in it. However, the string-match function doesn’t match the ‘]’ character. To demonstrate with an example, try the following funciton:

(string-match "[\\[\\]a-zA-Z]+" "Text[ab]”)

The result for the above function should have been a match structure with Text[ab] matched. However, the string-match returns #f which is incorrect. To test if the pattern I am using was right, I tried on regex101.com and it works. Here (https://regex101.com/r/VAl6aI/1) is the link that demonstrates that it works.

Hence, the above leads me to believe there is a bug in the regex library that mishandles ] character in character-classes

—

Regards,

Abdulrahman Semrie