Flash&ActionScript/ActionScript
2008/10/16 15:45
string.replace(pattern:*, repl:Object)
1. 검색 과정 중 처음에 발생하는 결과에 대해서만 교체가 이루어진다.
3. ignore (i)옵션을 붙여서 대소문자 구분없이 검색한다.
var myPattern:RegExp = /sh/; var str:String = "She sells seashells by the seashore."; trace(str.replace(myPattern, "sch")); // She sells seaschells by the seashore.2. global (g) 옵션을 붙여서 패턴과 같은 모든 결과에 대해 교체
var myPattern:RegExp = /sh/g; var str:String = "She sells seashells by the seashore."; trace(str.replace(myPattern, "sch")); // She sells seaschells by the seaschore.
var myPattern:RegExp = /sh/gi; var str:String = "She sells seashells by the seashore."; trace(str.replace(myPattern, "sch")); // sche sells seaschells by the seaschore.

