Get param for name - Node.js Regular expression

Node.js examples for Regular expression:Match

Description

Get param for name

Demo Code

function getParam(name){
   return (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search)) ?
      decodeURIComponent(name[1]) :
           "";//from w w  w .  j  a  v  a 2s .  c  o m
}

Related Tutorials