0
可能重複:
preg_match in JavaScript?的JavaScript的preg_match equivilent
我有這樣一個網址:
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中做到這一點?
這個問題中已經回答了什麼: http://stackoverflow.com/questions/3291289/preg-match-in-javascript – gernberg
感謝但如何在javascript中編寫模式,我試過了:var myregexp =#(\ d +)/(\ d +)/(\ d +)#;不工作 –
var myregexp = /(\ d +)\ /(\ d +)\ /(\ d +)/; 謝謝:) –