In javascript, when you call the match method, the RegExp object will hold onto the sub patterns so you can reference them after a match.
var str = ‘http://www.website.com/webpage.html’;
if (str.match( ‘([a-z]+\.com)’ )) {
alert( RegExp.$1 );
}
Alerts: ‘website.com’;
I learned about this from analyzing the iepnghack.htc code written by Aaron Porter.
Comments
Leave a Reply