本软件由HiFi小组编写,所以保留本关于,本人只是很喜欢他们的设计,但对于他们不回复我做出中文翻译并不理睬表示不解,因此转入自己的网站内,不过仍对做出这么好的验证器的人致以崇高的敬意。因为保留他们的商标是肯定侵权的,所以移除他们的商标并添加自己所作的。因为本人也是正则新手,所以肯定有不足、错误的地方,恳请各位大牛指正,邮箱:mengzhuo1203@gmail.com

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.

关闭

//g
处理选项:
  • 处理选项:
var regex = //; var input = "请输入您的字符"; 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("没有匹配项!"); }