幫助輕松構建正規表達式的JavaScript類庫:VerbalExpressions
VerbalExpressions是一個幫助輕松構建正規表達式的JavaScript類庫。
還其它編程語言的移植實現:
// Create an example of how to test for correctly formed URLs var tester = VerEx() .startOfLine() .then( "http" ) .maybe( "s" ) .then( "://" ) .maybe( "www." ) .anythingBut( " " ) .endOfLine();// Create an example URL var testMe = "
// Use RegExp object's native test() function if( tester.test( testMe ) ) alert( "We have a correct URL "); // This output will fire else alert( "The URL is incorrect" );
console.log( tester ); // Ouputs the actual expression used: /^(http)(s)?(\:\/\/)(www.)?([^\ ]</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!