0

Possible Duplicate:
preg_match in JavaScript?

I have a url like this:

http://localhost/nafham/?selection/12/24/122

Using PHP I can do:

preg_match("#(\d+)/(\d+)/(\d+)#", $_SERVER['REQUEST_URI'], $regs)
$edu_year = $regs[1];
$semester = $regs[2];
$subject = $regs[3];

How can I do this in javascript?

Community
  • 1
  • 1
Mohamed Said
  • 4,413
  • 6
  • 35
  • 52

1 Answers1

1

String .match is what you are looking for or regex.exec

read http://www.w3schools.com/jsref/jsref_match.asp

and http://www.regular-expressions.info/javascript.html

Sully
  • 14,672
  • 5
  • 54
  • 79