Nate Weiner

This is an old archived post from my former blog The Idea Shower. It's where I cataloged my product explorations and releases, one of which ultimately became Pocket.

This post was published back in 2007. It may not function as originally intended or may be missing images.

RegExp Object Subpatterns

September 01, 2007

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.