需要用正則表達式幫助JavaScript的正則表達式窗口PARAMS
var s = "left=123,top=345,width=123, height= 34, center=yes, help=no,resizable=yes, status=now";
需要得到所有PARAMS(名稱 - >值)
試過這樣/(\w+)\s?=(\S+)[\s|,]/
結果:
array(3) {
[0] =>
array(3) {
[0] =>
string(28) "left=123,top=345,width=123, "
[1] =>
string(12) "center=yes, "
[2] =>
string(23) "help=no,resizable=yes, "
}
[1] =>
array(3) {
[0] =>
string(4) "left"
[1] =>
string(6) "center"
[2] =>
string(4) "help"
}
[2] =>
array(3) {
[0] =>
string(22) "123,top=345,width=123,"
[1] =>
string(4) "yes,"
[2] =>
string(17) "no,resizable=yes,"
}
}
''(\ S +)''匹配可能過多字符。試試nongreedy版本''(\ S +?)'' – Hachi 2012-08-14 09:15:30
請參閱http://stackoverflow.com/questions/901115/get-query-string-values-in-javascript – Stefan 2012-08-14 09:20:34