firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.26k stars 199 forks source link

Suggestions for Interface Improvement #2150

Open Serious54088 opened 1 year ago

Serious54088 commented 1 year ago

Feature

222

Hello!

As shown in the above picture, those are my suggestions for improving the user interface of regex101.

Let me explain why I'm proposing these changes.

First, it's important to recognize this fact:

One of the most common use cases for regular expressions is in search boxes, like searching or replacing in various text editors or note-taking software.

For users in this scenario, all they need to consider in the search box is the regular expression itself. They don't need to think about creating regex objects or escaping the delimiters in literals.

For example, if you need to find a string like "23/03" in the Typora editor , you just need to type "\d{2}/\d{2}" in Typora’s search box. You don't need to think about using /"\d{2}\/\d{2}"/g or new RegExp("\"\\d{2}/\\d{2}\"") . (The additional escaping of / , " and \ in these two expressions is something to consider at the programming language level, but not for the regex itself.)

Now, let's look at what issues arise when a user enters "\d{2}/\d{2}" in regex101's regex input field (assuming the Flavor is Javascript):

Therefore, my suggestion is to remove extra escaping warnings at the programming language level. (only raise errors if the regex itself is invalid). Instead, add more copy options to cater to different scenarios.

For example, if you need to use the regex in Typora's search box, you can click the option Copy Regex As Is, and you will get the regex itself: "\d{2}/\d{2}". If you wish to create a regex object by constructor function in JavaScript code, you can click the option Copy Regex As "" String,then you will get new RegExp("\"\\d{2}/\\d{2}\"", "gm") ...

This will make regex101 more friendly and useful whether for programers or non-programmers. Looking forward to your reply.

firasdib commented 8 months ago

I understand where you're coming from, but I feel that simply copying the regex from the input field is very easy and straight forward for the cases where you just want the regex?

And with regards to the errors, I think those should remain, as they are valid for that language.