forked from: regular expression bug @ String.replace(RegExp, function(){});
forked from regular expression bug @ String.replace(RegExp, function(){}); (diff: 43)
ActionScript3 source code
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/xaLG
*/
// forked from 9re's regular expression bug @ String.replace(RegExp, function(){});
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.utils.ByteArray;
import flash.accessibility.Accessibility;
public class FlashTest extends Sprite {
public function FlashTest() {
var str:String = 'マルチバイト http://twitter.com/ ascii http://google.com';
var ba:ByteArray = new ByteArray;
ba.writeUTFBytes(str);
ba.position = 0;
var tf:TextField = new TextField;
var i:int = 0;
var regURL:RegExp = new RegExp("https?://[-_.!~*a-zA-Z0-9;/?:@&=+$,%#]+", "g");
var match:Object;
while (true) {
match = regURL.exec(str);
if (!match) break;
tf.appendText('index : ' + match.index + "\n");
tf.appendText('match : ' + match + '\n');
}
tf.width = tf.textWidth + 4;
addChild(tf);
function trace(...o):void {
tf.appendText(o + '\n');
}
}
}
}