标签: javascript regex
可能重复: preg_match in JavaScript?
我有这样的网址:
http://localhost/nafham/?selection/12/24/122
使用PHP我可以做到:
preg_match("#(\d+)/(\d+)/(\d+)#", $_SERVER['REQUEST_URI'], $regs) $edu_year = $regs[1]; $semester = $regs[2]; $subject = $regs[3];
我怎样才能在javascript中执行此操作?
答案 0 :(得分:1)
字符串.match正是您要找的或regex.exec
.match
阅读http://www.w3schools.com/jsref/jsref_match.asp
和http://www.regular-expressions.info/javascript.html