Web Development Blog

24K Design Studio :: Blog :: Javascript: Regular expression tester.
Javascript: Regular expression tester.
12:10, 21 Sep, 2010
by David

If you are using javascript, you might probably meets regular expression later or sooner.
What's the easiest way? Learning it and writing your own expression is one choice. However, as long as its something common, it is almost impossible to do better than others did that before.
So looking for code on the Internet is one best choice. What you found might have been used by millions of other programmer. After you find one, are you sure it can work and will you test it before actural using?

Manually testing is possible, but as a programmer, why not write a program to test it?

The code to create a regular expression is:
var reg = new RegExp(value, regParam);
  value is the regular expression.
  regParam can be g(globally),i(case-insensitive),m(multiline).
The code to apply it on a string is:
  str is the tested string.

With this basic testing code, it is possible to write a tester.
One working example can be found at http://daifei4321.com/jsreg/ (Prompts are in chinese)
The source code for that is the attachment of this entry.

Your name:
Only visible to the author.

Tell us you are not a robot. What is captcha1captchaOcaptcha2 =

View the latest 5 entries.