I am designing a regular expression tester in HTML and JavaScript. The user will enter a regex, a string, and choose the function they want to test with (e.g. search, match,
I suggest you also add separate checkboxes or a textfield for the special flags. That way it is clear that the user does not need to add any //
's. In the case of a replace, provide two textfields. This will make your life a lot easier.
Why? Because otherwise some users will add //
's while other will not. And some will make a syntax error. Then, after you stripped the //
's, you may end up with a syntactically valid regex that is nothing like what the user intended, leading to strange behaviour (from the user's perspective).