Inside a Flash use a regular expression of type

Related Tags:

  Inside a Flash use a regular expression category, the reasons for the use of this class is FLASH text input on the inside of the main requirement, for example, will not be able to detect the importation of mail in the correct format; 
  (Class RegExp 
  Public var const: String = null; 
  Public var source: String = null; 
  Public var global: Boolean = false; 
  Public var ignoreCase: Boolean = false; 
  Public var multiline: Boolean = false; 
  Public var lastIndex: Number = null; 
  Public static var _xrStatic: Number = null; 
  Public var _xr: Number = null; 
  Public static var _xp: Number = null; 
  Public static var _xxa: Array = null; 
  Public static var _xxlp: Number = null; 
  Public var _xq: Number = null; 
  Public var _xqc: Number = null; 
  Public static var d: Number = null; 
  Public static var _xiStatic: Number = null; 
  Public var _xi: Number = 0; 
  Public static var _xxlm: String = null; 
  Public static var _xxlc: String = null; 
  Public static var _xxrc: String = null; 
  Public static var lastMatch: String = null; 
  Public static var leftContext: String = null; 
  Public static var rightContext: String = null; 
  Public static var _xa: Array = new Array (); 
  Public static var lastParen: String = null; 
  Public static var _xaStatic: Array = new Array (); 
  Public static var $ 1: String = null; 
  Public static var $ 2: String = null; 
  Public static var $ 3: String = null; 
  Public static var $ 4: String = null; 
  Public static var $ 5: String = null; 
  Public static var $ 6: String = null; 
  Public static var $ 7: String = null; 
  Public static var $ 8: String = null; 
  Public static var $ 9: String = null; 
  Private static var _setString: Boolean = RegExp.setStringMethods (); 

  Function RegExp () ( 
  If (arguments [0] == null) ( 
  Else () 
  Const = "RegExp"; 
  Compile.apply (this, arguments); 
  ) 
  ) 
  Public function invStr (sVal: String): String ( 
  Var s = sVal; 
  Var l = length (s); 
  Var j; 
  Var c; 
  Var r = ""; 
  For (var i = 1; i <255; i) ( 
  C = chr (i); 
  J = 0; 
  While (j <= l & substring (s, 1 j, 1)! = C) ( 
  ) 
  If (j> l) ( 
  R = c; 
  ) 
  ) 
  Return s; 
  ) 
  Public function compile () ( 
  This.source = arguments [0]; 
  If (arguments.length> 1) ( 
  Var flags = ([1] arguments''). ToLowerCase (); 
  For (var i = 0; i <length (flags); i) ( 
  If (substring (flags, i 1, 1) == "g") ( 
  This.global = true; 
  ) 
  If (substring (flags, i 1, 1) == "i") ( 
  This.ignoreCase = true; 
  ) 
  If (substring (flags, i 1, 1) == "m") ( 
  This.multiline = true; 
  ) 
  ) 
  ) 
  If (arguments.length <3) ( 
  Var root = true; 
  RegExp._xrStatic = 1; 
  / / Paren counter 
  Var i = 0; 
  Else () 
  Var root = false; 
  This._xr = RegExp._xrStatic; 
  Var i = arguments [2]; 
  ) 
  This.lastIndex = 0; 
  / * 
  Compile the regular expression 
  The array of character definition objects will be created: 
  Q [n]. T -> type of match required: 0 = exact 
  1 = in char set 
  2 = not in char set 
  3 = paren 
  4 = ref to paren 
  7 = new "OR" section 
  9 = beginning of line 
  10 = end of line 
  Q [n]. S -> character or character set 
  Q [n]. A -> character has to repeat at least a times 
  Q [n]. B -> character has to repeat at most b times 
  * / 
  Var re = this.source; 
  Var ex; 
  Var l = length (re); 
  Var q = []; 
  Var qc = 0; 
  Var s; 
  Var range = false; 
  Var ca; 
  Var cb; 
  Var atEnd = false; 
  Var char; 
  For (i = i; i <l; i) ( 
  Var thischar = substring (re, i 1, 1); 
  If (thischar == "\ \") ( 
  I; 
  Char = false; 
  Thischar = substring (re, i 1, 1); 
  Else () 
  Char = true; 
  ) 
  Var nextchar = substring (re, i 2, 1); 
  Q [qc] = new Object (); 
  Q [qc]. T = 0; 
  Q [qc]. A = 0; 
  Q [qc]. B = 999; 
  Q [qc]. C = 10; 
  If (char) ( 
  / / Handle special characters 
  If (thischar == "(") ( 
  / / Opening paren 
  Ex = new RegExp (re, (this.ignoreCase? "Gi": "g"), i 1); 
  I = RegExp._xiStatic; 
  Q [qc]. T = 3; 
  Thischar = ex; 
  Nextchar = substring (re, i 2, 1); 
  ) Else if (! Root & thischar == ")") ( 
  / / Closing paren 
  Break; 
  ) Else if (thischar == "^") ( 
  / / Must be located at the beginning of string / line 
  If (qc == 0 | | q [qc-1]. T == 7) ( 
  Q [qc]. T = 9; 
  Q [qc]. A = 1; 
  Q [qc]. B = 1; 
  Qc; 
  ) 
  Continue; 
  ) Else if (thischar == "$") ( 
  / / Must be located at the end of string / line 
  If (root) ( 
  AtEnd = true; 
  ) 
  Continue; 
  ) Else if (thischar == "[") ( 
  / / This is a character set 
  I; 
  If (nextchar == "^") ( 
  Q [qc]. T = 2; 
  I; 
  Else () 
  Q [qc]. T = 1; 
  ) 
  Thischar = ""; 
  Range = false; 
  While (i <l & & (s = substring (re, an i, 1))! = "]") ( 
  If (range) ( 
  / / Previous char was "-" and so create a range 
  If (s == "\ \") ( 
  ) 
  Cb = s = "\ \"? (S == "b"? Chr (8): substring (re, an i, 1)): s; 
  Ca = ord (substring (thischar, length (thischar), 1)); 
  While (cb> = (s = chr (ca))) ( 
  Thischar = s; 
  ) 
  Range = false; 
  Else () 
  If (s == "-" & & length (thischar)> 0) ( 
  / / Character range is being defined 
  Range = true; 
  Else () 
  If (s == "\ \") ( 
  / / Predefined char set may follow 
  S = substring (re, an i, 1); 
  If (s == "d") ( 
  Thischar = "0123456789"; 
  ) Else if (s == "D") ( 
  Thischar = invStr ( "0123456789"); 
  ) Else if (s == "s") ( 
  Thischar = "\ f \ n \ r \ t \ v"; 
  ) Else if (s == "S") ( 
  InvStr thischar = ( "\ f \ n \ r \ t \ v"); 
  ) Else if (s == "w") ( 
  Thischar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; 
  ) Else if (s == "W") ( 
  Thischar = invStr ( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"); 
  ) Else if (s == "b") ( 
  Thischar = chr (8); 
  ) Else if (s == "\ \") ( 
  Thischar = s; 
  ) 
  Else () 
  Thischar = s; 
  ) 
  ) 
  ) 
  ) 
  If (range) thischar = "-"; 
  I -; 
  Var nextchar = substring (re, i 2, 1); 
  ) Else if (thischar == "|") ( 
  / / OR section 
  If (atEnd) ( 
  Q [qc]. T = 10; 
  Q [qc]. A = 1; 
  Q [qc]. B = 1; 
  Qc; 
  Q [qc] = new Object (); 
  AtEnd = false; 
  ) 
  Q [qc]. T = 7; 
  Q [qc]. A = 1; 
  Q [qc]. B = 1; 
  Qc; 
  Continue; 
  ) Else if (thischar == ".") ( 
  Q [qc]. T = 2; 
  Thischar = "\ n"; 
  ) Else if (thischar == "*" | | thischar == "?" | | Thischar == "") ( 
  Continue; 
  ) 
  Else () 
  If (thischar> = "1" & thischar <= "9") ( 
  Q [qc]. T = 4; 
  ) Else if (thischar == "b") ( 
  Q [qc]. T = 1; 
  Thischar = "- wb -"; 
  ) Else if (thischar == "B") ( 
  Q [qc]. T = 2; 
  Thischar = "- wb -"; 
  ) Else if (thischar == "d") ( 
  Q [qc]. T = 1; 
  Thischar = "0123456789"; 
  ) Else if (thischar == "D") ( 
  Q [qc]. T = 2; 
  Thischar = "0123456789"; 
  ) Else if (thischar == "s") ( 
  Q [qc]. T = 1; 
  Thischar = "\ f \ n \ r \ t \ v"; 
  ) Else if (thischar == "S") ( 
  Q [qc]. T = 2; 
  Thischar = "\ f \ n \ r \ t \ v"; 
  ) Else if (thischar == "w") ( 
  Q [qc]. T = 1; 
  Thischar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; 
  ) Else if (thischar == "W") ( 
  Q [qc]. T = 2; 
  Thischar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_"; 
  ) 
  ) 
  / / Counting metacharacters 
  If (nextchar == "*") ( 
  Q [qc]. Thischar = s; 
  Qc; 
  I; 
  ) Else if (nextchar == "") ( 
  Q [qc]. Thischar = s; 
  Q [qc]. B = 1; 
  Qc; 
  I; 
  ) Else if (nextchar == "") ( 
  Q [qc]. Thischar = s; 
  Q [qc]. A = 1; 
  Qc; 
  I; 
  ) Else if (nextchar == "(") ( 
  Var comma = false; 
  Var rangeA = 0; 
  Range = ""; 
  I; 
  While (i 1 <l & & (s = substring (re, 2 i, 1))! = ")") ( 
  If (! Comma & s == "") ( 
  Comma = true; 
  RangeA = Number (range); 
  RangeA = Math.floor (isNaN (rangeA)? 0: rangeA); 
  If (rangeA <0) ( 
  RangeA = 0; 
  ) 
  Range = ""; 
  Else () 
  Range = s; 
  ) 
  ) 
  Var rangeB = Number (range); 
  RangeB = Math.floor (isNaN (rangeB)? 0: rangeB); 
  If (rangeB <1) ( 
  RangeB = 999; 
  ) 
  If (rangeB <rangeA) ( 
  RangeB = rangeA; 
  ) 
  Q [qc]. Thischar = s; 
  Q [qc]. B = rangeB; 
  Q [qc]. = A comma? RangeA: rangeB; 
  Qc; 
  Else () 
  Q [qc]. Thischar = s; 
  Q [qc]. A = 1; 
  Q [qc]. B = 1; 
  Qc; 
  ) 
  ) 
  If (root & atEnd) ( 
  Q [qc] = new Object (); 
  Q [qc]. T = 10; 
  Q [qc]. A = 1; 
  Q [qc]. B = 1; 
  Qc; 
  ) 
  If (! Root) ( 
  RegExp._xiStatic = i; 
  This.source = substring (re, arguments [2] 1, i-arguments [2]); 
  ) 
  If (RegExp.d) ( 
  For (var i = 0; i <qc; i) ( 
  Trace ( "xr" this._xr '' q [i]. T ":" q [i]. A ":" q [i]. B ":" q [i]. S); 
  ) 
  ) 
  This._xq = q; 
  This._xqc = qc; 
  RegExp._xp = 0; 
  ) 
  Public function test () ( 
  If (RegExp._xp == 0) ( 
  RegExp._xxa = []; 
  / / Temp array for storing paren matches 
  RegExp._xxlp = 0; 
  / / Last paren 
  ) 
  / / Q [n]. C -> count of matches 
  / / Q [n]. I -> index within the string 
  Var str arguments [0] =''; 
  Var re; 
  Var q = this._xq; 
  Var qc = this._xqc; 
  Var qb; 
  Var c; 
  Var cl; 
  Var ct; 
  Var s; 
  Var l = length (str); 
  Var ix = this.global? This.lastIndex: 0; 
  Var ix_ = ix; 
  Var str_ = str; 
  If (this.ignoreCase) ( 
  Str = str.toLowerCase (); 
  ) 
  Var r = new Object (); 
  Ri = -1; 
  Var i = 1; 
  While (i <qc-1) ( 
  I; 
  If (RegExp.d) ( 
  Trace ( "New section started at i =" i); 
  ) 
  Ix = ix_; 
  Qb = i; 
  Q [qb]. C = 10; 
  Var atEnd = false; 
  While (i> qb | | ix <l 1) ( 
  If (q [i]. T == 7) ( 
  / / New "OR" section coming 
  Break; 
  ) Else if (q [i]. T == 9) ( 
  I; 
  If (i == qb 1) ( 
  Var atStart = true; 
  Qb = i; 
  ) 
  Q [qb]. C = 10; 
  Continue; 
  Else () 
  If (ri> = 0 & & ix> = ri) ( 
  / / There is already better match, so quit searching 
  Break; 
  ) 
  If (q [i]. C == -10) ( 
  If (RegExp.d) ( 
  Trace ( "Lookup #" i "at index" ix "for \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ '" q [i]. S "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 'type "q [i]. t); 
  ) 
  / / Count the # of matches 
  Var m = 0; 
  Q [i]. Ix = i; 
  If (q [i]. T == 0) ( 
  / / Exact match 
  C = this.ignoreCase? Q [i]. S.toLowerCase (): q [i]. S; 
  While (m <q [i]. B & ix <l) ( 
  If (substring (str, 1 ix, 1) == c) ( 
  M; 
  Ix; 
  Else () 
  Break; 
  ) 
  ) 
  ) Else if (q [i]. T == 1) ( 
  / / In char set 
  If (q [i]. S == "- wb -") ( 
  Q [i]. A = 1; 
  If (ix> 0 & & ix <l) ( 
  Ct = substring (str, ix, 1); 
  If (ct == "" | | ct == "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n") ( 
  M = 1; 
  ) 
  If (m == 0) ( 
  Ct = substring (str, 1 ix, 1); 
  If (ct == "" | | ct == "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n") ( 
  M = 1; 
  ) 
  ) 
  Else () 
  M = 1; 
  ) 
  Else () 
  C = this.ignoreCase? Q [i]. S.toLowerCase (): q [i]. S; 
  Cl = length (c); 
  Var cs; 
  While (m <q [i]. B & ix <l) ( 
  Ct = substring (str, 1 ix, 1); 
  Cs = 0; 
  While (cs <= cl & substring (c, 1 cs, 1)! = Ct) ( 
  ) 
  If (cs <= cl) ( 
  M; 
  Ix; 
  Else () 
  Break; 
  ) 
  ) 
  ) 
  ) Else if (q [i]. T == 2) ( 
  / / Not in char set 
  C = this.ignoreCase? Q [i]. S.toLowerCase (): q [i]. S; 
  Cl = length (c); 
  If (q [i]. S == "- wb -") ( 
  Q [i]. A = 1; 
  If (ix> 0 & & ix <l) ( 
  Ct = substring (str, ix, 1); 
  S = substring (str, 1 ix, 1); 
  If (ct! = "" & & Ct! = "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ N" & s! = "" & & S! = "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n ") ( 
  M = 1; 
  ) 
  Else () 
  M = 0; 
  ) 
  Else () 
  While (m <q [i]. B & ix <l) ( 
  Ct = substring (str, 1 ix, 1); 
  Cs = 0; 
  While (cs <= cl & substring (c, 1 cs, 1)! = Ct) ( 
  ) 
  If (cs <= cl) ( 
  Break; 
  Else () 
  M; 
  Ix; 
  ) 
  ) 
  ) 
  ) Else if (q [i]. T == 10) ( 
  / / End of string / line must be next 
  S = substring (str, 1 ix, 1); 
  M = (this.multiline & & (s == "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n" | | s = "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ r ")) | | ix == l? 1: 0; 
  ) Else if (q [i]. T == 3) ( 
  / / Regular expression in parens 
  Re = q [i]. S; 
  Q [i]. Ix = []; 
  Q [i]. Ix [m] = ix; 
  / / Save index if need to retreat 
  Re.lastIndex = ix; 
  While (m <q [i]. B & re.test (str_)) ( 
  Cl = length (RegExp._xxlm); 
  If (cl> 0) ( 
  Ix = cl; 
  M; 
  Q [i]. Ix [m] = ix; 
  Else () 
  M = q [i]. A; 
  Q [i]. Ix [m-1] = ix; 
  Break; 
  ) 
  ) 
  If (m == 0) ( 
  RegExp._xxlm = ""; 
  ) 
  If (re._xr> RegExp._xxlp) ( 
  RegExp._xxlp = re._xr; 
  ) 
  RegExp._xxa [Number (re._xr)] = RegExp._xxlm; 
  ) Else if (q [i]. T == 4) ( 
  / / Back reference to paren 
  If (RegExp._xp> = (c = Number (q [i]. S))) ( 
  C = RegExp._xxa [c]; 
  C = this.ignoreCase? C.toLowerCase (): c; 
  Cl = length (c); 
  Q [i]. Ix = []; 
  Q [i]. Ix [m] = ix; 
  If (cl> 0) ( 
  While (m <q [i]. B & ix <l) ( 
  If (substring (str, 1 ix, cl) == c) ( 
  M; 
  Ix = cl; 
  Q [i]. Ix [m] = ix; 
  Else () 
  Break; 
  ) 
  ) 
  Else () 
  M = 0; 
  Q [i]. A = 0; 
  ) 
  Else () 
  / / Paren is not ready, treat number as charcode 
  C = chr (c); 
  Q [i]. Ix = []; 
  Q [i]. Ix [m] = ix; 
  While (m <q [i]. B & ix <l) ( 
  If (substring (str, 1 ix, 1) == c) ( 
  M; 
  Ix; 
  Q [i]. Ix [m] = ix; 
  Else () 
  Break; 
  ) 
  ) 
  ) 
  ) 
  Q [i]. C = m; 
  If (RegExp.d) ( 
  Trace ( "" m "matches found"); 
  ) 
  ) 
  If (q [i]. C <q [i]. A) ( 
  If (RegExp.d) ( 
  Trace ( "not enough matches"); 
  ) 
  / / Not enough matches 
  If (i> qb) ( 
  / / Retreat back and decrease of assumed matches # 
  I -; 
  Q [i]. C -; 
  If (q [i]. C> = 0) ( 
  Ix = (q [i]. T == 3 | | q [i]. T == 4)? Q [i]. Ix [q [i]. C]: (q [i]. Iq [i] . c); 
  ) 
  If (RegExp.d) ( 
  Trace ( "Retreat to #" i "c =" q [i]. C "index =" ix); 
  ) 
  Else () 
  If (RegExp._xp> 1) ( 
  / / If this is a paren, failing to find first match is fatal 
  Break; 
  ) 
  If (atStart) ( 
  / / Match must be at the start of string / line 
  If (this.multiline) ( 
  / / Jump to the beginning of the next line 
  While (ix <= l) ( 
  S = substring (str, 1 ix, 1); 
  If (s == "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ n" | | s = "\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ r") ( 
  Break; 
  ) 
  ) 
  Q [i]. C = 10; 
  Else () 
  / / No match 
  Break; 
  ) 
  Else () 
  / / Start a new search from next position 
  Ix; 
  Q [i]. C = 10; 
  ) 
  ) 
  Else () 
  If (RegExp.d) ( 
  Trace ( "enough matches!"); 
  ) 
  / / # Of matches ok, proceed to next 
  I; 
  If (i == qc | | q [i]. T == 7) ( 
  If (RegExp.d) ( 
  Trace ( "Saving better result: ri = q [" qb "]. I =" q [qb] i); 
  ) 
  Ri = q [qb]. I; 
  R.li = ix; 
  Break; 
  Else () 
  Q [i]. C = 10; 
  ) 
  ) 
  ) 
  ) 
  While (i <qc & q [i]. T! = 7) ( 
  I; 
  ) 
  / / Jump to the next "OR" section 
  ) 
  If (ri <0) ( 
  This.lastIndex = 0; 
  If (RegExp._xp-- == 1) ( 
  RegExp._xxa = []; 
  RegExp._xxlp = 0; 
  ) 
  Return false; 
  Else () 
  Ix = r.li; 
  This._xi = ri; 
  RegExp._xxlm = substring (str_, ri 1, ix-ri); 
  RegExp._xxlc = substring (str_, 1, ri); 
  RegExp._xxrc = substring (str_, ix 1, l-ix); 
  If (ix == ri) ( 
  Ix; 
  ) 
  This.lastIndex = ix; 
  If (RegExp._xp-- == 1) ( 
  RegExp.lastMatch = RegExp._xxlm; 
  RegExp.leftContext = RegExp._xxlc; 
  RegExp.rightContext = RegExp._xxrc; 
  RegExp._xaStatic = RegExp._xxa; 
  RegExp._xxa RegExp.lastParen = [Number (RegExp._xxlp)]; 
  For (i = 1; i <10; i) ( 
  RegExp [ "$" i] = RegExp._xaStatic [Number (i)]; 
  ) 
  ) 
  Return true; 
  ) 
  ) 
  Public function exec () ( 
  Var str arguments [0] =''; 
  If (str =='') ( 
  Return false; 
  ) 
  Var t = this.test (str); 
  If (t) ( 
  Var ra = new Array (); 
  Ra.index = this._xi; 
  Ra.input = str; 
  Ra [0] = RegExp.lastMatch; 
  Var l = RegExp._xaStatic.length; 
  For (var i = 1; i <l; i) ( 
  Ra RegExp._xaStatic [i] = [Number (i)]; 
  ) 
  Else () 
  Var ra = null; 
  ) 
  Return ra; 
  ) 
  Public static function setStringMethods () ( 
  If (String.prototype.match! = Undefined) ( 
  Return; 
  ) 
  String.prototype.match = function () ( 
  If (typeof (arguments [0])! = "Object") ( 
  Return null; 
  ) 
  If (arguments [0]. Const! = "RegExp") ( 
  Return null; 
  ) 
  Var re = arguments [0]; 
  Var s = this.valueOf (); 
  Var ip = 0; 
  Var rc = 0; 
  If (re.global) ( 
  Re.lastIndex = 0; 
  While (re.test (s)) ( 
  If (rc == 0) ( 
  Var ra = new Array (); 
  ) 
  Ra [rc] = RegExp.lastMatch; 
  Ip = re.lastIndex; 
  ) 
  Re.lastIndex = ip; 
  Else () 
  Var ra = re.exec (s); 
  Rc; 
  ) 
  Return (rc == 0)? Null: ra; 
  ); 
  String.prototype.replace = function () ( 
  If (typeof (arguments [0])! = "Object") ( 
  Return null; 
  ) 
  If (arguments [0]. Const! = "RegExp") ( 
  Return null; 
  ) 
  Var re = arguments [0]; 
  Var rs arguments [1] =''; 
  Var s = this; 
  Var r = ""; 
  Re.lastIndex = 0; 
  If (re.global) ( 
  Var ip = 0; 
  Var ix = 0; 
  While (re.test (s)) ( 
  / / Replace backreferences in rs 
  Var i = 0; 
  Var l = length (rs); 
  Var c = ""; 
  Var pc = ""; 
  Var nrs = ""; 
  While (i <l) ( 
  C = substring (rs 1 i, 1); 
  If (c == "$" & pc! = "\ \") ( 
  C = substring (rs 1 i, 1); 
  If (isNaN (Number (c)) | | Number (c)> 9) ( 
  Nrs = "$" c; 
  Else () 
  Nrs = RegExp._xaStatic [Number (c)]; 
  ) 
  Else () 
  Nrs = c; 
  ) 
  Pc = c; 
  ) 
  R = substring (s, ix 1, re._xi-ix) nrs; 
  Ix = re._xi length (RegExp.lastMatch); 
  Ip = re.lastIndex; 
  ) 
  Re.lastIndex = ip; 
  Else () 
  If (re.test (s)) ( 
  R = RegExp.leftContext rs; 
  ) 
  ) 
  R = re.lastIndex == 0? S: RegExp.rightContext; 
  Return r; 
  ); 
  String.prototype.search = function () ( 
  If (typeof (arguments [0])! = "Object") ( 
  Return null; 
  ) 
  If (arguments [0]. Const! = "RegExp") ( 
  Return null; 
  ) 
  Var re = arguments [0]; 
  Var s = this; 
  Re.lastIndex = 0; 
  Var t = re.test (s); 
  Return t? Re._xi: 1; 
  ); 
  String.prototype.old_split = String.prototype.split; 
  String.prototype.split = function () ( 
  If (typeof (arguments [0]) == "object" & arguments [0]. Const == "RegExp") ( 
  Var re = arguments [0]; 
  Var lm = arguments [1] == null? 9999: Number (arguments [1]); 
  If (isNaN (lm)) ( 
  Lm = 9999; 
  ) 
  Var s = this; 
  Var ra = new Array (); 
  Var rc = 0; 
  Var gs = re.global; 
  Re.global = true; 
  Re.lastIndex = 0; 
  Var ip = 0; 
  Var ipp = 0; 
  Var ix = 0; 
  While (rc <lm & re.test (s)) ( 
  / / Trace (re._xi "" ix "" RegExp.lastMatch); 
  If (re._xi! = Ix) ( 
  Ra [rc] = substring (s, ix 1, re._xi-ix); 
  ) 
  Ix = re._xi length (RegExp.lastMatch); 
  Ipp = ip; 
  Ip = re.lastIndex; 
  ) 
  If (rc == lm) ( 
  Re.lastIndex = ipp; 
  Else () 
  Re.lastIndex = ip; 
  ) 
  If (rc == 0) ( 
  Ra [rc] = s; 
  Else () 
  If (rc <lm && length(RegExp.rightContext)> 0) ( 
  Ra [rc] = RegExp.rightContext; 
  ) 
  ) 
  Re.global = gs; 
  Return ra; 
  Else () 
  Return this.old_split (arguments [0], [1] arguments); 
  ) 
  ); 
  Return true; 
  ) 
  ) Example: 
  Var re = new RegExp ( "\ w (3)", "i"); 
  Trace (re.test ( "ABC")); 

Related articles:

Learning REST
  Learning REST    REST by Roy Fielding, in his thesis on "Architectural Styles and the Design of Network-based Software Architectures" in a term.    REST English Representational State Transfer is the abbreviation of a Chinese translation for "as a state t...
Pages of text explain the rolling code
  Basic syntax    <marquee> ... </ Marquee>    Mobile text attribute settings    Direction    <direction=#> # = Left, right <marquee direction=left> from right to the left!    </ Marquee>    Way ...
Web Standard on the road at the foot
  WEB has just begun to accept the standard in June of 2004, then there are some classics master who is discussing a new things.    I am not sure what the time is, anyway DIV + CSS is not only feel quite interesting, to get to see.    Experts have found is not talking about ...
CSS memorandum (Float, Position, Div, inline)
  CSS knowledge point.    For example: the CSS Float, Positon, inline, compatibility, etc..    Following a summary of the contents of the browser is used: Firfox2.0, IE7    Float relevant:    With a floating label after block-level elements and the ele...
Who will enter?
  This is a very interesting article, perhaps, the text in a browser, you may also choose to follow.    What is your answer?    One woman go outside and see the front yard sat three Changbai a beard for the elderly.    She did not know them.    So sai...