javascript regexp exec

regexp.exec 滅多に使わないけど、こんな出力だったんだなと

var str = ‘[0-9]+';
var re = new RegExp( ‘[0-9]+’, ‘g’ );
// re = /[0-9]+/g
var st = ‘あい876うえお全 100件全 99件';
var result = re.exec(st);
console.log(result);
var result = st.match(re);
console.log(result);
$ node test_regexp
[ '876', index: 2, input: 'あい876うえお全 100件全 99件' ]
[ '876', '100', '99' ]

execだとindexとinputが返ってくるようです。何か必要なこともあるかもしれませんね。

This entry was posted on 火曜日, 4月 16th, 2013 at 8:04 PM and is filed under Javascript. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Unityによるゲームを公開しております iOS/Android
https://itunes.apple.com/jp/app/lost-knight-3d-action/id900917032
https://play.google.com/store/apps/details?id=com.groundroad.runknight

各種開発支援・機能開発等小さいお仕事などもお請けしております。
unity開発支援, PHPシステム開発, javascript/html5 フロント開発, titanium mobileアプリ開発
お気軽にお問い合わせください
大崎・五反田近郊での対面でのお打ち合わせはいつでも可能です。