Regular expression examples in javascript

来源:互联网 发布:最佳网络投资平台 编辑:程序博客网 时间:2024/06/08 05:24

Email validation

* /^[0-9a-zA-Z]{3,20}@([0-9a-zA-Z]?.)+[0-9a-zA-Z]{2,10}$/ **

Url parsing

* /^([a-zA-Z]{2,8}:\/\/)?(.?)(\/.?){1}(\?.)?$/ **
Assume that result is the matched result returned, then
result[0]: the complete string that match the regular expression;
result[1]: the first matched group, the protocol http or https here;
result[2]: the second matched group, domain name;
result[3]: the third matched group, path;
result[4]: the fourth matched group, query string, which could be present or absent.

0 0
原创粉丝点击