Changeset 2609
- Timestamp:
- 06/26/03 00:45:22 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/j/src/gnu/regexp/REMatch.java
r2 r2609 55 55 copy.next = null; 56 56 57 copy.start = (int[]) start.clone(); 58 copy.end = (int[]) end.clone(); 57 // Jun 25 2003 3:39 PM PG 58 // Work around problem with jikes 1.18 and IBM Java 1.4.1. 59 //copy.start = (int[]) start.clone(); 60 //copy.end = (int[]) end.clone(); 61 copy.start = new int[start.length]; 62 System.arraycopy(start, 0, copy.start, 0, start.length); 63 copy.end = new int[end.length]; 64 System.arraycopy(end, 0, copy.end, 0, end.length); 59 65 60 66 return copy; … … 97 103 next = null; // cut off alternates 98 104 } 99 105 100 106 /** Clears the current match and moves the offset to the new index. */ 101 107 void clear(int index) { … … 107 113 next = null; // cut off alternates 108 114 } 109 115 110 116 /** 111 117 * Returns the string matching the pattern. This makes it convenient 112 118 * to write code like the following: 113 119 * <P> 114 * <code> 120 * <code> 115 121 * REMatch myMatch = myExpression.getMatch(myString);<br> 116 122 * if (myMatch != null) System.out.println("Regexp found: "+myMatch); … … 120 126 return matchedText; 121 127 } 122 128 123 129 /** 124 130 * Returns the index within the input text where the match in its entirety … … 128 134 return offset + start[0]; 129 135 } 130 136 131 137 /** 132 138 * Returns the index within the input string where the match in … … 144 150 * <P> 145 151 * But you can save yourself that work, since the <code>toString()</code> 146 * method (above) does exactly that for you. 152 * method (above) does exactly that for you. 147 153 */ 148 154 public int getEndIndex() { 149 155 return offset + end[0]; 150 156 } 151 157 152 158 /** 153 159 * Returns the string matching the given subexpression. The subexpressions … … 162 168 return (matchedText.substring(start[sub],end[sub])); 163 169 } 164 165 /** 170 171 /** 166 172 * Returns the index within the input string used to generate this match 167 173 * where subexpression number <i>sub</i> begins, or <code>-1</code> if … … 176 182 return (x == -1) ? x : offset + x; 177 183 } 178 179 /** 184 185 /** 180 186 * Returns the index within the input string used to generate this match 181 187 * where subexpression number <i>sub</i> begins, or <code>-1</code> if … … 190 196 return (x == -1) ? x : offset + x; 191 197 } 192 193 /** 198 199 /** 194 200 * Returns the index within the input string used to generate this match 195 201 * where subexpression number <i>sub</i> ends, or <code>-1</code> if … … 204 210 return (x == -1) ? x : offset + x; 205 211 } 206 207 /** 212 213 /** 208 214 * Returns the index within the input string used to generate this match 209 215 * where subexpression number <i>sub</i> ends, or <code>-1</code> if … … 217 223 return (x == -1) ? x : offset + x; 218 224 } 219 225 220 226 /** 221 227 * Substitute the results of this match to create a new string. … … 236 242 if (val < start.length) { 237 243 output.append(toString(val)); 238 } 244 } 239 245 } else output.append(input.charAt(pos)); 240 246 }
Note: See TracChangeset
for help on using the changeset viewer.