Last active
August 29, 2015 14:17
-
-
Save jasonleonhard/dffe06632348c46ac4ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// This will match an email given any string | |
// note even my ' in the string was fine ;D | |
var re = /[\w]+@[\w-]+\.[\w]+/g; | |
var str2 = "my email is not [email protected] it's actually [email protected]"; | |
var myArray = str2.match(re); | |
myArray | |
//search inside just a target <tag> in DevTools console using RegEx | |
//1. then convert that object into a string | |
var text = $('<div>').append($('#file-gistfile1-txt-LC4').clone()).html(); text; | |
// "<div class="line" id="file-gistfile1-txt-LC4" style="display: block;">var str2 = "my email is not [email protected] it's actually [email protected]";</div>" | |
//2. and then use regex to match just emails (of that new string only) | |
var re = /[\w]+@[\w-]+\.[\w]+/g; | |
var myArray = text.match(re); myArray | |
//["[email protected]", "[email protected]"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment