HiFi Regex Tester

This tool was created to help developers learn, test, and write regular expressions. It is written entirely in JavaScript, HTML, and CSS to provide live validation and match feedback on your regexs. This tool relies on JavaScript's regular expression engine which uses perl regex syntax.

Regular Expression Validator

As you type your regular expression the background of the box will indicate whether your regex is valid. Red means your regular expression is currently invalid. This will happen when writing matching groups and classes are opened without close, forward slashes are unescaped, etc. Yellow indicates a valid regular expression that does not match any of your input text. Green indicates both a valid expression and a match in your input.

Regex Match

You can click on the main text area to edit the input test your regular expression will match against. General regex matches will be highlighted in yellow. If your regular expression uses matching groups the groups will be highlighted in other colors, too. Finally, regexp matches will be printed in the match table below your input.

Regular Expression Syntax Reference

To the right of the tool is a cheat sheet for quick reference on the syntax of regular expressions. It is organized by the primary features of the perl regex language.

Regular Expression Examples

Here are a few quick regex examples to get you started:

  • Matching a 10-digit US Phone Number
    Regex: \D?(\d{3})\D?(\d{3})\D?(\d{4})
    Match Against: 123-456-7890 1234567890 (123)456-7890
  • Words starting with a capital letter
    Regex: [A-Z][a-z]*
    Match Against: Hello World this does not Match!
  • HTML Tags
    Regex <(\/?\w+)[^>]*>
    Match Against: <a href="http://gethifi.com">HiFi CMS</a>

Who created this tool?

The team behind HiFi, a next-generation CMS for designers. You should follow us on Twitter and check out our development blog for other interesting JavaScript and web tools like our Sitemap Creator.

Close

//g
Flags:
  • Flags:
var regex = //; var input = "your input string"; if(regex.test(input)) { var match = input.match(regex); alert(match);var matches = input.match(regex); for(var match in matches) { alert(matches[match]); } } else { alert("No matches found!"); }