1
16
17 import org.as2lib.regexp.AsciiUtil;
18 import org.as2lib.regexp.node.Node;
19 import org.as2lib.regexp.node.TreeInfo;
20
21
28
29 class org.as2lib.regexp.node.BackRefA extends Node {
30
31 private var groupIndex:Number;
32
33 public function BackRefA(groupCount:Number) {
34 super();
35 groupIndex = groupCount + groupCount;
36 }
37
38 public function match(matcher:Object, i:Number, seq:String):Boolean {
39 var j:Number = matcher.groups[groupIndex];
40 var k:Number = matcher.groups[groupIndex+1];
41
42 var groupSize:Number = k - j;
43
44
45 if (j < 0) return false;
46
47
48 if (i + groupSize > matcher.to) return false;
49
50
51
52 for (var index=0; index<groupSize; index++) {
53 var c1:Number = seq.charCodeAt(i+index);
54 var c2:Number = seq.charCodeAt(j+index);
55 if (c1 != c2) {
56 c1 = AsciiUtil.toUpper(c1);
57 c2 = AsciiUtil.toUpper(c2);
58 if (c1 != c2) {
59 c1 = AsciiUtil.toLower(c1);
60 c2 = AsciiUtil.toLower(c2);
61 if (c1 != c2) return false;
62 }
63 }
64 }
65
66 return next.match(matcher, i+groupSize, seq);
67 }
68
69 public function study(info:TreeInfo):Boolean {
70 info.maxValid = false;
71 return next.study(info);
72 }
73 }
74
75