//regex 正则表达式 import com; namespace string; class regex{ ctor(pattern){ this = ..com.CreateObject("{3F4DACA4-160D-11D2-A8E9-00104B365C9F}") ; this.Pattern = pattern; this.Global = true; }; gmatch = function(str,pattern){ this.Global = true; if(pattern) this.Pattern = pattern; var colMatches = this.Execute(str); return ..com.each(colMatches) }; match = function(str,pattern){ this.Global = false; if(pattern) this.Pattern = pattern; var colMatches = this.Execute(str); if(colMatches && colMatches.Count){ return colMatches[0]; } }; find = function(str,pattern){ if(pattern) this.Pattern = pattern return this.Test(str); }; replace = function(str,pattern,replStr){ this.Global = true; if(pattern) this.Pattern = pattern; return this.Replace(str,replStr); }; } namespace regex{ gmatch = function(str, pattern) { var re = ..string.regex(pattern) var next = re.gmatch(str); return function(){ var m = next(); if(!m) { ..com.Release(re) return; } var matches = m.SubMatches; var count = m.SubMatches.Count; if(count){ var result = {} for(i=0;i