javascript에서 정규식 사용
match(), test(), new RegExp("pattern","flags")
matchedValue = /pattern/.exec(value); str.replace(/pattern/, toStr);
ex:
var filename = '20080919114201'; var requestTime = filename.replace(/^(....)(..)(..)(..)(..)(..)$/, "$1-$2-$3 $4:$5:$6");--> 결과
2008-09-19 11:42:01
- match()
var str="Hello world!"; document.write(str.match("world") + "<br />"); document.write(str.match("World") + "<br />"); document.write(str.match("worlld") + "<br />"); document.write(str.match("world!"));--> 결과
world null null world!
- test()
RegExpObject.test(string)