回答編集履歴

1

コードの修正

2015/08/26 05:42

投稿

hirohiro
hirohiro

スコア2068

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  str = "http://sample.jp/sample/category/2?site_domain=sample ";
10
10
 
11
- trg = str.match(/\/(\d)\?/i);
11
+ trg = str.match(/\/(\d+)\?/i); //\dを\d+に修正しました。
12
12
 
13
13
  if(trg)trg=trg[1]; // trg=2
14
14