In this example you can get all occurrences of an email address on the web page. Useful if you have to change the email address for a specific page or sub section of your site. Might be useful to screen scrape email addresses off web pages too, although that’s not what i am trying to achieve here. See more jQuery .each Examples.

i = insensitive (case)
g= global search
m = match over multiple lines

var iframeSrc = 'test.html?param=value&email=noobs@noob.com&moreparams=values';
var emailRegex= /[._a-zA-Z0-9-]+@[._a-zA-Z0-9-]+/igm;

console.log(iframeSrc);
console.log(emailRegex.test(iframeSrc));
console.log(iframeSrc.match(emailRegex));

$.each(iframeSrc.match(emailRegex), function(index, value) { 
     console.log(index + ". " + value);
});
//output: 0. noobs@noob.com

This find all html between the tags:

var secureQueryRegex = /()/igm;
/* loop for each query found in data */
$.each(data.match(secureQueryRegex), function(index, value) {
	console.log(index + ". " + value);
});
//example output: 
//0. query=find all shops
//1. query=find all locations
//etc...
Sam Deering is a Front-end Web Developer who specialises in JavaScript & jQuery. Sam is driven and passionate about sharing his knowledge to educate others.

Free Guide:

How to Choose the Right Charting Library for Your Application

How do you make sure that the charting library you choose has everything you need? Sign up to receive this detailed guide from FusionCharts, which explores all the factors you need to consider before making the decision.


  • http://webmastersintexas.com jery

    What do I do with the Jquery? I am still learning it.

Learn JavaScript for free!
Free course: Introduction to JavaScript

Yours when you take up a free 14-day SitePoint Premium trial.