Last active
August 29, 2015 14:13
-
-
Save noel9999/45c081f96c308f65c11e to your computer and use it in GitHub Desktop.
js regExp 練習
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = 'there are a lot of great websites like www.missingmanuals.com and http://www.noelsaga.com' | |
var urlRegex = /((\bhttps?:\/\/)|(\bwww\.))\S*/g | |
var url = text.match(urlRegex) | |
console.log(url[0]) | |
console.log(url[1]); | |
//看看兩者的差異 | |
var text2 = 'my website is www.noelsaga.com' | |
var urlRegex2 = /((\bhttps?:\/\/)|(\bwww\.))\S*/ | |
var url2 = text2.match(urlRegex2) | |
console.log(url2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment