Nate Weiner

  • Archive
  • RSS

RegExp Object Subpatterns

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.

    • #javascript
    • #regular-expressions
  • 4 years ago
  • 1
  • Permalink
  • Share
    Tweet

1 Notes/ Hide

  1. nateweiner posted this
← Previous • Next →

About

Prototyper, water waster, developer of Read It Later.

 

Follow

Twitter: @NateWeiner
Vimeo: Nate Weiner
500px: Nate Weiner
Blog: RSS

Pages

  • Contact
  • RSS
  • Random
  • Archive
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr