gskinner / regexr

RegExr is a HTML/JS based tool for creating, testing, and learning about Regular Expressions.
http://regexr.com/
GNU General Public License v3.0
9.81k stars 967 forks source link

Unicode char code \u{code} not recognized when it contains letter #358

Open Tayflo opened 4 years ago

Tayflo commented 4 years ago

Hello there. First of all thanks a lot for RegExr, it's such a great and easy-to-use tool, it's almost a daily companion for me ๐Ÿ‘

Description

I noticed a little bug: using unicode flag, unicode escaped characters that contains letters in their code don't print properly in the explanation box (both in the "Explain" tab in the tools box at the bottom, and in the expression input box on top).

Example

Looking for character \u{0020} (/\u{0020}/u), it matches perfectly space character, no problem.

Looking for character \u{002A} (/\u{002A}/u) 1) it matches asterisk (*) characters in the text box, "Replace", "List", "Details" tools tab (no prob) BUT 2) it displays the following error message in the "Explain" tab and the Expression box:

\u ERROR: Invalid escape sequence.

(And I know that brackets are not needed for four-char long unicode codes and \u002A works fine, but I use them for five-char long ones and the bug is the same.)

Thanks again for your time ๐Ÿ™‚

iansan5653 commented 4 years ago

I wrote a library a while back that might be helpful for resolving this depending on how the escape sequences are being handled - https://github.com/iansan5653/unraw.