javascript 用 regex 取出所要字串
字串 abcd[0102] 想取出 0102
- 方法一:用 substr var rc = "abcd[0102]".substr(5,4);
- 方法二:用 regex var arr_rc = /^.*\[(\d+)\].*/.exec("abcd[0102]"); //取出符合我字串,第一個本身,第二個(),陣列從 0 開始
var rc = arr_rc[1];
方法二利用 partten 取出 [] 內的數字,不管前面有幾位都可以
迴響
javascript 用 regex 取出所要字串 | 豬窩
Today, I went to the beachfront with my children. I found a sea shell and gave it to my
4 year old daughter and said "You can hear the ocean if you put this to your ear." She placed
the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear.
She never wants to go back! LoL I know this
is entirely off topic but I had to tell someone!
javascript 用 regex 取出所要字串 | 豬窩
I’m not that much of a internet reader to be honest but your blogs
really nice, keep it up! I'll go ahead and bookmark your website to come back down the road.
Many thanks
javascript 用 regex 取出所要字串 | 豬窩
Spot on with this write-up, I honestly think this site needs a great deal more attention. I'll
probably be back again to read through more, thanks for the information!