X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fas3%2Fok%2Fregexp.as;fp=lib%2Fas3%2Fok%2Fregexp.as;h=c041eecb5212054533ce5a8d066bbbe2bfcfbe60;hb=f3eda46129cad25e526f8f93cd154508713e33bc;hp=0000000000000000000000000000000000000000;hpb=ae39de536b42b7a69bd2691cc7fee486c3bd0b0a;p=swftools.git diff --git a/lib/as3/ok/regexp.as b/lib/as3/ok/regexp.as new file mode 100644 index 0000000..c041eec --- /dev/null +++ b/lib/as3/ok/regexp.as @@ -0,0 +1,33 @@ + +package { + import flash.display.MovieClip + + public class Main extends flash.display.MovieClip { + public function Main() { + /* test matching */ + var r:RegExp = /ok \d\/\d/; + trace("ok 1/7".match(r)); + + /* test searching */ + var s:String = "error OK 9/7 ok 2/7" + trace(s.substring(s.search(r))); + + /* test /.../i syntax */ + var r2:RegExp = /ok \d\/\d/i; + var s2:String = "error OK 3/7" + var s3:String = "error ok 3/7" + trace(s3.substring(s2.search(r2))); + + /* test \n,\r,\t */ + if(" .\n\r\t".search(/[\n][\r][\t]/) == 2) trace("ok 4/7"); + + /* test * at end of regexp */ + if(" xxx ".search(/xx*/) == 2) trace("ok 5/7"); + + /* test quotes */ + if(" \" ".search(/"/) == 1) trace("ok 6/7"); + if(' \' '.search(/'/) == 1) trace("ok 7/7"); + } + } +} +