stringのindexOfの挙動を確認する
♥0 |
Line 21 |
Modified 2009-09-29 10:56:59 |
MIT License
archived:2017-03-20 16:05:05
ActionScript3 source code
/**
* Copyright mmlemon_ ( http://wonderfl.net/user/mmlemon_ )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/g4Fm
*/
package {
import flash.display.Sprite;
import flash.text.*;
public class FlashTest extends Sprite {
private var tf:TextField;
public function FlashTest() {
// write as3 code here..
init();
}
private function init():void
{
tf = new TextField();
addChild(tf);
var ext:String = ".html";
var str:String = "sample.html?jklsjkrl#jsjkrl";
var index:int = str.indexOf(ext);
tf.text = index.toString();
// .html以降の文字列を削除したものを取得
var ans:String = str.substr(0, index + ext.length);
tf.appendText(" " + ans);
}
}
}