Thursday, December 13, 2012

JavaScript Regular Expressions

javascript-regular-expressions

Match & followed by anything except amp;

var test1 = "&";
var test2 = "&fake";
alert(test1+" finds "+test1.search(/&(?!amp;)/));
alert(test2+" finds "+test2.search(/&(?!amp;)/));

Match & followed by anything except amp; or lt;

var test1 = "hello & world < now";
var test2 = "hello & world < now >";
alert(test1+" finds "+test1.search(/&(?!amp;|lt;)/));
alert(test2+" finds "+test2.search(/&(?!amp;|lt;)/));

Try it at jsfiddle.net

web
{ "loggedin": false, "owner": false, "avatar": "", "render": "nothing", "trackingID": "UA-36983794-1", "description": "", "page": { "blogIds": [ 379 ] }, "domain": "holtstrom.com", "base": "\/michael", "url": "https:\/\/holtstrom.com\/michael\/", "frameworkFiles": "https:\/\/holtstrom.com\/michael\/_framework\/_files.4\/", "commonFiles": "https:\/\/holtstrom.com\/michael\/_common\/_files.3\/", "mediaFiles": "https:\/\/holtstrom.com\/michael\/media\/_files.3\/", "tmdbUrl": "http:\/\/www.themoviedb.org\/", "tmdbPoster": "http:\/\/image.tmdb.org\/t\/p\/w342" }