MCPcopy Create free account
hub / github.com/google/re2j / substring

Method substring

java/com/google/re2j/Matcher.java:382–394  ·  view source on GitHub ↗

Helper: return substring for [start, end).

(int start, int end)

Source from the content-addressed store, hash-verified

380
381 /** Helper: return substring for [start, end). */
382 String substring(int start, int end) {
383 // UTF_8 is matched in binary mode. So slice the bytes.
384 if (matcherInput.getEncoding() == Encoding.UTF_8) {
385 try {
386 return new String(matcherInput.asBytes(), start, end - start, "UTF-8");
387 } catch (UnsupportedEncodingException e) {
388 throw new RuntimeException(e); // Not possible.
389 }
390 }
391
392 // This is fast for both StringBuilder and String.
393 return matcherInput.asCharSequence().subSequence(start, end).toString();
394 }
395
396 /** Helper for Pattern: return input length. */
397 int inputLength() {

Callers 15

groupMethod · 0.95
appendReplacementMethod · 0.95
appendTailMethod · 0.95
unquoteMethod · 0.80
utf16IndicesToUtf8Method · 0.80
testRE2Method · 0.80
utf16IndicesToUtf8Method · 0.80
parseResultMethod · 0.80
testFowlerMethod · 0.80
parseFowlerResultMethod · 0.80

Calls 4

getEncodingMethod · 0.45
asBytesMethod · 0.45
toStringMethod · 0.45
asCharSequenceMethod · 0.45

Tested by 8

unquoteMethod · 0.64
utf16IndicesToUtf8Method · 0.64
testRE2Method · 0.64
utf16IndicesToUtf8Method · 0.64
parseResultMethod · 0.64
testFowlerMethod · 0.64
parseFowlerResultMethod · 0.64