001package Torello.Java; 002 003import java.util.Vector; 004import java.util.function.Predicate; 005import java.util.stream.IntStream; 006 007/** 008 * The purpose of this class is to help find the location of {@code Token-Matches} inside 009 * of an input source-{@code String}. 010 * 011 * <EMBED CLASS='external-html' DATA-FILE-ID=STR_TOKINDEX_OF> 012 */ 013@Torello.JavaDoc.StaticFunctional 014@Torello.JavaDoc.JDHeaderBackgroundImg 015@Torello.JavaDoc.CSSLinks(FileNames="Strings.css") 016public class StrTokIndexOf 017{ 018 private StrTokIndexOf() { } 019 020 /** 021 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 022 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 023 * {@code 'srcStr'} indicating where matches have occured. 024 * 025 * <BR /><BR /><DIV CLASS=JDHint> 026 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 027 * </DIV> 028 * 029 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 030 * 031 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 032 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 033 * will be returned. 034 * 035 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 036 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 037 * 038 * @param c This is the character that will be 'searched-for' in input-parameter 039 * {@code String 'srcStr'}. 040 * 041 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 042 * 043 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 044 * {@code java.lang.String}-indices where matches were found. 045 * 046 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 047 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 048 * 049 * @throws StringIndexOutOfBoundsException 050 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 051 */ 052 public static int[] all_CI 053 (String srcStr, int sPos, int ePos, char c, Predicate<Character> extraDelimiterTest) 054 { 055 LV l = new LV(srcStr, sPos, ePos); 056 IntStream.Builder b = IntStream.builder(); 057 058 c = Character.toLowerCase(c); 059 060 for (int i=l.start; i < l.end; i++) 061 062 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 063 && ( (i==0) 064 || Character.isWhitespace(srcStr.charAt(i-1)) 065 || extraDelimiterTest.test(srcStr.charAt(i-1))) 066 && ( ((i+1) == srcStr.length()) 067 || Character.isWhitespace(srcStr.charAt(i+1)) 068 || extraDelimiterTest.test(srcStr.charAt(i+1))) 069 ) 070 b.accept(i); 071 072 return b.build().toArray(); 073 } 074 075 /** 076 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 077 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 078 * {@code 'srcStr'} indicating where matches have occured. 079 * 080 * <BR /><BR /><DIV CLASS=JDHint> 081 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 082 * </DIV> 083 * 084 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 085 * 086 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 087 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 088 * will be returned. 089 * 090 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 091 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 092 * 093 * @param c This is the character that will be 'searched-for' in input-parameter 094 * {@code String 'srcStr'}. 095 * 096 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 097 * {@code java.lang.String}-indices where matches were found. 098 * 099 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 100 * 101 * @throws StringIndexOutOfBoundsException 102 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 103 */ 104 public static int[] all_CI(String srcStr, int sPos, int ePos, char c) 105 { 106 LV l = new LV(srcStr, sPos, ePos); 107 IntStream.Builder b = IntStream.builder(); 108 109 c = Character.toLowerCase(c); 110 111 for (int i=l.start; i < l.end; i++) 112 113 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 114 && ( (i==0) 115 || Character.isWhitespace(srcStr.charAt(i-1))) 116 && ( ((i+1) == srcStr.length()) 117 || Character.isWhitespace(srcStr.charAt(i+1))) 118 ) 119 b.accept(i); 120 121 return b.build().toArray(); 122 } 123 124 /** 125 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 126 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 127 * {@code 'srcStr'} indicating where matches have occured. 128 * 129 * <BR /><BR /><DIV CLASS=JDHint> 130 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 131 * </DIV> 132 * 133 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 134 * 135 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 136 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 137 * will be returned. 138 * 139 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 140 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 141 * 142 * @param token This is the sub-string that will be 'searched-for' in input-parameter 143 * {@code String 'srcStr'}. 144 * 145 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 146 * 147 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 148 * {@code java.lang.String}-indices where matches were found. 149 * 150 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 151 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 152 * 153 * @throws StringIndexOutOfBoundsException 154 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 155 */ 156 public static int[] all_CI 157 (String srcStr, int sPos, int ePos, String token, Predicate<Character> extraDelimiterTest) 158 { 159 LV l = new LV(srcStr, sPos, ePos, token.length()); 160 IntStream.Builder b = IntStream.builder(); 161 int tokenLen = token.length(); 162 163 for (int i=l.start; i < l.end; i++) 164 165 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 166 && ( (i==0) 167 || Character.isWhitespace(srcStr.charAt(i-1)) 168 || extraDelimiterTest.test(srcStr.charAt(i-1))) 169 && ( ((i + tokenLen) == srcStr.length()) 170 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 171 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 172 ) 173 b.accept(i); 174 175 return b.build().toArray(); 176 } 177 178 /** 179 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 180 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 181 * {@code 'srcStr'} indicating where matches have occured. 182 * 183 * <BR /><BR /><DIV CLASS=JDHint> 184 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 185 * </DIV> 186 * 187 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 188 * 189 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 190 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 191 * will be returned. 192 * 193 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 194 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 195 * 196 * @param token This is the sub-string that will be 'searched-for' in input-parameter 197 * {@code String 'srcStr'}. 198 * 199 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 200 * {@code java.lang.String}-indices where matches were found. 201 * 202 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 203 * 204 * @throws StringIndexOutOfBoundsException 205 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 206 */ 207 public static int[] all_CI(String srcStr, int sPos, int ePos, String token) 208 { 209 LV l = new LV(srcStr, sPos, ePos, token.length()); 210 IntStream.Builder b = IntStream.builder(); 211 int tokenLen = token.length(); 212 213 for (int i=l.start; i < l.end; i++) 214 215 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 216 && ( (i==0) 217 || Character.isWhitespace(srcStr.charAt(i-1))) 218 && ( ((i + tokenLen) == srcStr.length()) 219 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 220 ) 221 b.accept(i); 222 223 return b.build().toArray(); 224 } 225 226 /** 227 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 228 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 229 * {@code 'srcStr'} indicating where matches have occured. 230 * 231 * <BR /><BR /><DIV CLASS=JDHint> 232 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 233 * </DIV> 234 * 235 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 236 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 237 * will be returned. 238 * 239 * @param c This is the character that will be 'searched-for' in input-parameter 240 * {@code String 'srcStr'}. 241 * 242 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 243 * 244 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 245 * {@code java.lang.String}-indices where matches were found. 246 * 247 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 248 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 249 */ 250 public static int[] all_CI(String srcStr, char c, Predicate<Character> extraDelimiterTest) 251 { 252 LV l = new LV(srcStr, 0, -1); 253 IntStream.Builder b = IntStream.builder(); 254 255 c = Character.toLowerCase(c); 256 257 for (int i=l.start; i < l.end; i++) 258 259 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 260 && ( (i==0) 261 || Character.isWhitespace(srcStr.charAt(i-1)) 262 || extraDelimiterTest.test(srcStr.charAt(i-1))) 263 && ( ((i+1) == srcStr.length()) 264 || Character.isWhitespace(srcStr.charAt(i+1)) 265 || extraDelimiterTest.test(srcStr.charAt(i+1))) 266 ) 267 b.accept(i); 268 269 return b.build().toArray(); 270 } 271 272 /** 273 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 274 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 275 * {@code 'srcStr'} indicating where matches have occured. 276 * 277 * <BR /><BR /><DIV CLASS=JDHint> 278 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 279 * </DIV> 280 * 281 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 282 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 283 * will be returned. 284 * 285 * @param c This is the character that will be 'searched-for' in input-parameter 286 * {@code String 'srcStr'}. 287 * 288 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 289 * {@code java.lang.String}-indices where matches were found. 290 * 291 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 292 */ 293 public static int[] all_CI(String srcStr, char c) 294 { 295 LV l = new LV(srcStr, 0, -1); 296 IntStream.Builder b = IntStream.builder(); 297 298 c = Character.toLowerCase(c); 299 300 for (int i=l.start; i < l.end; i++) 301 302 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 303 && ( (i==0) 304 || Character.isWhitespace(srcStr.charAt(i-1))) 305 && ( ((i+1) == srcStr.length()) 306 || Character.isWhitespace(srcStr.charAt(i+1))) 307 ) 308 b.accept(i); 309 310 return b.build().toArray(); 311 } 312 313 /** 314 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 315 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 316 * {@code 'srcStr'} indicating where matches have occured. 317 * 318 * <BR /><BR /><DIV CLASS=JDHint> 319 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 320 * </DIV> 321 * 322 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 323 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 324 * will be returned. 325 * 326 * @param token This is the sub-string that will be 'searched-for' in input-parameter 327 * {@code String 'srcStr'}. 328 * 329 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 330 * 331 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 332 * {@code java.lang.String}-indices where matches were found. 333 * 334 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 335 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 336 */ 337 public static int[] all_CI 338 (String srcStr, String token, Predicate<Character> extraDelimiterTest) 339 { 340 LV l = new LV(srcStr, 0, -1, token.length()); 341 IntStream.Builder b = IntStream.builder(); 342 int tokenLen = token.length(); 343 344 for (int i=l.start; i < l.end; i++) 345 346 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 347 && ( (i==0) 348 || Character.isWhitespace(srcStr.charAt(i-1)) 349 || extraDelimiterTest.test(srcStr.charAt(i-1))) 350 && ( ((i + tokenLen) == srcStr.length()) 351 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 352 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 353 ) 354 b.accept(i); 355 356 return b.build().toArray(); 357 } 358 359 /** 360 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 361 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 362 * {@code 'srcStr'} indicating where matches have occured. 363 * 364 * <BR /><BR /><DIV CLASS=JDHint> 365 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 366 * </DIV> 367 * 368 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 369 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 370 * will be returned. 371 * 372 * @param token This is the sub-string that will be 'searched-for' in input-parameter 373 * {@code String 'srcStr'}. 374 * 375 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 376 * {@code java.lang.String}-indices where matches were found. 377 * 378 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 379 */ 380 public static int[] all_CI(String srcStr, String token) 381 { 382 LV l = new LV(srcStr, 0, -1, token.length()); 383 IntStream.Builder b = IntStream.builder(); 384 int tokenLen = token.length(); 385 386 for (int i=l.start; i < l.end; i++) 387 388 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 389 && ( (i==0) 390 || Character.isWhitespace(srcStr.charAt(i-1))) 391 && ( ((i + tokenLen) == srcStr.length()) 392 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 393 ) 394 b.accept(i); 395 396 return b.build().toArray(); 397 } 398 399 /** 400 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 401 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 402 * {@code 'srcStr'} indicating where matches have occured. 403 * 404 * <BR /><BR /><DIV CLASS=JDHint> 405 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 406 * </DIV> 407 * 408 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 409 * 410 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 411 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 412 * will be returned. 413 * 414 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 415 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 416 * 417 * @param c This is the character that will be 'searched-for' in input-parameter 418 * {@code String 'srcStr'}. 419 * 420 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 421 * 422 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 423 * {@code java.lang.String}-indices where matches were found. 424 * 425 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 426 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 427 * 428 * @throws StringIndexOutOfBoundsException 429 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 430 */ 431 public static int[] all 432 (String srcStr, int sPos, int ePos, char c, Predicate<Character> extraDelimiterTest) 433 { 434 LV l = new LV(srcStr, sPos, ePos); 435 IntStream.Builder b = IntStream.builder(); 436 437 for (int i=l.start; i < l.end; i++) 438 439 if ( (c == srcStr.charAt(i)) 440 && ( (i==0) 441 || Character.isWhitespace(srcStr.charAt(i-1)) 442 || extraDelimiterTest.test(srcStr.charAt(i-1))) 443 && ( ((i+1) == srcStr.length()) 444 || Character.isWhitespace(srcStr.charAt(i+1)) 445 || extraDelimiterTest.test(srcStr.charAt(i+1))) 446 ) 447 b.accept(i); 448 449 return b.build().toArray(); 450 } 451 452 /** 453 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 454 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 455 * {@code 'srcStr'} indicating where matches have occured. 456 * 457 * <BR /><BR /><DIV CLASS=JDHint> 458 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 459 * </DIV> 460 * 461 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 462 * 463 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 464 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 465 * will be returned. 466 * 467 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 468 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 469 * 470 * @param c This is the character that will be 'searched-for' in input-parameter 471 * {@code String 'srcStr'}. 472 * 473 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 474 * {@code java.lang.String}-indices where matches were found. 475 * 476 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 477 * 478 * @throws StringIndexOutOfBoundsException 479 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 480 */ 481 public static int[] all(String srcStr, int sPos, int ePos, char c) 482 { 483 LV l = new LV(srcStr, sPos, ePos); 484 IntStream.Builder b = IntStream.builder(); 485 486 for (int i=l.start; i < l.end; i++) 487 488 if ( (c == srcStr.charAt(i)) 489 && ( (i==0) 490 || Character.isWhitespace(srcStr.charAt(i-1))) 491 && ( ((i+1) == srcStr.length()) 492 || Character.isWhitespace(srcStr.charAt(i+1))) 493 ) 494 b.accept(i); 495 496 return b.build().toArray(); 497 } 498 499 /** 500 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 501 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 502 * {@code 'srcStr'} indicating where matches have occured. 503 * 504 * <BR /><BR /><DIV CLASS=JDHint> 505 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 506 * </DIV> 507 * 508 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 509 * 510 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 511 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 512 * will be returned. 513 * 514 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 515 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 516 * 517 * @param token This is the sub-string that will be 'searched-for' in input-parameter 518 * {@code String 'srcStr'}. 519 * 520 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 521 * 522 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 523 * {@code java.lang.String}-indices where matches were found. 524 * 525 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 526 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 527 * 528 * @throws StringIndexOutOfBoundsException 529 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 530 */ 531 public static int[] all 532 (String srcStr, int sPos, int ePos, String token, Predicate<Character> extraDelimiterTest) 533 { 534 LV l = new LV(srcStr, sPos, ePos, token.length()); 535 IntStream.Builder b = IntStream.builder(); 536 int tokenLen = token.length(); 537 538 for (int i=l.start; i < l.end; i++) 539 540 if ( srcStr.regionMatches(i, token, 0, tokenLen) 541 && ( (i==0) 542 || Character.isWhitespace(srcStr.charAt(i-1)) 543 || extraDelimiterTest.test(srcStr.charAt(i-1))) 544 && ( ((i + tokenLen) == srcStr.length()) 545 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 546 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 547 ) 548 b.accept(i); 549 550 return b.build().toArray(); 551 } 552 553 /** 554 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 555 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 556 * {@code 'srcStr'} indicating where matches have occured. 557 * 558 * <BR /><BR /><DIV CLASS=JDHint> 559 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 560 * </DIV> 561 * 562 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 563 * 564 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 565 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 566 * will be returned. 567 * 568 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 569 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 570 * 571 * @param token This is the sub-string that will be 'searched-for' in input-parameter 572 * {@code String 'srcStr'}. 573 * 574 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 575 * {@code java.lang.String}-indices where matches were found. 576 * 577 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 578 * 579 * @throws StringIndexOutOfBoundsException 580 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 581 */ 582 public static int[] all(String srcStr, int sPos, int ePos, String token) 583 { 584 LV l = new LV(srcStr, sPos, ePos, token.length()); 585 IntStream.Builder b = IntStream.builder(); 586 int tokenLen = token.length(); 587 588 for (int i=l.start; i < l.end; i++) 589 590 if ( srcStr.regionMatches(i, token, 0, tokenLen) 591 && ( (i==0) 592 || Character.isWhitespace(srcStr.charAt(i-1))) 593 && ( ((i + tokenLen) == srcStr.length()) 594 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 595 ) 596 b.accept(i); 597 598 return b.build().toArray(); 599 } 600 601 /** 602 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 603 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 604 * {@code 'srcStr'} indicating where matches have occured. 605 * 606 * <BR /><BR /><DIV CLASS=JDHint> 607 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 608 * </DIV> 609 * 610 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 611 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 612 * will be returned. 613 * 614 * @param c This is the character that will be 'searched-for' in input-parameter 615 * {@code String 'srcStr'}. 616 * 617 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 618 * 619 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 620 * {@code java.lang.String}-indices where matches were found. 621 * 622 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 623 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 624 */ 625 public static int[] all(String srcStr, char c, Predicate<Character> extraDelimiterTest) 626 { 627 LV l = new LV(srcStr, 0, -1); 628 IntStream.Builder b = IntStream.builder(); 629 630 for (int i=l.start; i < l.end; i++) 631 632 if ( (c == srcStr.charAt(i)) 633 && ( (i==0) 634 || Character.isWhitespace(srcStr.charAt(i-1)) 635 || extraDelimiterTest.test(srcStr.charAt(i-1))) 636 && ( ((i+1) == srcStr.length()) 637 || Character.isWhitespace(srcStr.charAt(i+1)) 638 || extraDelimiterTest.test(srcStr.charAt(i+1))) 639 ) 640 b.accept(i); 641 642 return b.build().toArray(); 643 } 644 645 /** 646 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code char}-parameter 647 * {@code 'c'} in {@code 'srcStr'}, and return an integer-array of index-locations into 648 * {@code 'srcStr'} indicating where matches have occured. 649 * 650 * <BR /><BR /><DIV CLASS=JDHint> 651 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 652 * </DIV> 653 * 654 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 655 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 656 * will be returned. 657 * 658 * @param c This is the character that will be 'searched-for' in input-parameter 659 * {@code String 'srcStr'}. 660 * 661 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 662 * {@code java.lang.String}-indices where matches were found. 663 * 664 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 665 */ 666 public static int[] all(String srcStr, char c) 667 { 668 LV l = new LV(srcStr, 0, -1); 669 IntStream.Builder b = IntStream.builder(); 670 671 for (int i=l.start; i < l.end; i++) 672 673 if ( (c == srcStr.charAt(i)) 674 && ( (i==0) 675 || Character.isWhitespace(srcStr.charAt(i-1))) 676 && ( ((i+1) == srcStr.length()) 677 || Character.isWhitespace(srcStr.charAt(i+1))) 678 ) 679 b.accept(i); 680 681 return b.build().toArray(); 682 } 683 684 /** 685 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 686 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 687 * {@code 'srcStr'} indicating where matches have occured. 688 * 689 * <BR /><BR /><DIV CLASS=JDHint> 690 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 691 * </DIV> 692 * 693 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 694 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 695 * will be returned. 696 * 697 * @param token This is the sub-string that will be 'searched-for' in input-parameter 698 * {@code String 'srcStr'}. 699 * 700 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 701 * 702 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 703 * {@code java.lang.String}-indices where matches were found. 704 * 705 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 706 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 707 */ 708 public static int[] all 709 (String srcStr, String token, Predicate<Character> extraDelimiterTest) 710 { 711 LV l = new LV(srcStr, 0, -1, token.length()); 712 IntStream.Builder b = IntStream.builder(); 713 int tokenLen = token.length(); 714 715 for (int i=l.start; i < l.end; i++) 716 717 if ( srcStr.regionMatches(i, token, 0, tokenLen) 718 && ( (i==0) 719 || Character.isWhitespace(srcStr.charAt(i-1)) 720 || extraDelimiterTest.test(srcStr.charAt(i-1))) 721 && ( ((i + tokenLen) == srcStr.length()) 722 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 723 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 724 ) 725 b.accept(i); 726 727 return b.build().toArray(); 728 } 729 730 /** 731 * Search for <B STYLE='color: red'>all</B> {@code token}-matches of{@code String}-param 732 * {@code 'token'} in {@code 'srcStr'}, and return an integer-array of index-locations into 733 * {@code 'srcStr'} indicating where matches have occured. 734 * 735 * <BR /><BR /><DIV CLASS=JDHint> 736 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 737 * </DIV> 738 * 739 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 740 * the specified {@code token}-matches, and an integer-array of {@code String}-index pointers 741 * will be returned. 742 * 743 * @param token This is the sub-string that will be 'searched-for' in input-parameter 744 * {@code String 'srcStr'}. 745 * 746 * @return An integer-pointer array of <B STYLE='color: red;'>all</B> 747 * {@code java.lang.String}-indices where matches were found. 748 * 749 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 750 */ 751 public static int[] all(String srcStr, String token) 752 { 753 LV l = new LV(srcStr, 0, -1, token.length()); 754 IntStream.Builder b = IntStream.builder(); 755 int tokenLen = token.length(); 756 757 for (int i=l.start; i < l.end; i++) 758 759 if ( srcStr.regionMatches(i, token, 0, tokenLen) 760 && ( (i==0) 761 || Character.isWhitespace(srcStr.charAt(i-1))) 762 && ( ((i + tokenLen) == srcStr.length()) 763 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 764 ) 765 b.accept(i); 766 767 return b.build().toArray(); 768 } 769 770 /** 771 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 772 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 773 * {@code 'srcStr'} where the match occured. 774 * 775 * <BR /><BR /><DIV CLASS=JDHint> 776 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 777 * </DIV> 778 * 779 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 780 * 781 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 782 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 783 * 784 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 785 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 786 * 787 * @param c This is the character that will be 'searched-for' in input-parameter 788 * {@code String 'srcStr'}. 789 * 790 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 791 * 792 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 793 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 794 * 795 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 796 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 797 * 798 * @throws StringIndexOutOfBoundsException 799 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 800 */ 801 public static int first_CI 802 (String srcStr, int sPos, int ePos, char c, Predicate<Character> extraDelimiterTest) 803 { 804 LV l = new LV(srcStr, sPos, ePos); 805 806 c = Character.toLowerCase(c); 807 808 for (int i=l.start; i < l.end; i++) 809 810 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 811 && ( (i==0) 812 || Character.isWhitespace(srcStr.charAt(i-1)) 813 || extraDelimiterTest.test(srcStr.charAt(i-1))) 814 && ( ((i+1) == srcStr.length()) 815 || Character.isWhitespace(srcStr.charAt(i+1)) 816 || extraDelimiterTest.test(srcStr.charAt(i+1))) 817 ) 818 return i; 819 820 return -1; 821 } 822 823 /** 824 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 825 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 826 * {@code 'srcStr'} where the match occured. 827 * 828 * <BR /><BR /><DIV CLASS=JDHint> 829 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 830 * </DIV> 831 * 832 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 833 * 834 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 835 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 836 * 837 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 838 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 839 * 840 * @param c This is the character that will be 'searched-for' in input-parameter 841 * {@code String 'srcStr'}. 842 * 843 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 844 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 845 * 846 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 847 * 848 * @throws StringIndexOutOfBoundsException 849 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 850 */ 851 public static int first_CI(String srcStr, int sPos, int ePos, char c) 852 { 853 LV l = new LV(srcStr, sPos, ePos); 854 855 c = Character.toLowerCase(c); 856 857 for (int i=l.start; i < l.end; i++) 858 859 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 860 && ( (i==0) 861 || Character.isWhitespace(srcStr.charAt(i-1))) 862 && ( ((i+1) == srcStr.length()) 863 || Character.isWhitespace(srcStr.charAt(i+1))) 864 ) 865 return i; 866 867 return -1; 868 } 869 870 /** 871 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 872 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 873 * {@code 'srcStr'} where the match occured. 874 * 875 * <BR /><BR /><DIV CLASS=JDHint> 876 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 877 * </DIV> 878 * 879 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 880 * 881 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 882 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 883 * 884 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 885 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 886 * 887 * @param token This is the sub-string that will be 'searched-for' in input-parameter 888 * {@code String 'srcStr'}. 889 * 890 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 891 * 892 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 893 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 894 * 895 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 896 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 897 * 898 * @throws StringIndexOutOfBoundsException 899 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 900 */ 901 public static int first_CI 902 (String srcStr, int sPos, int ePos, String token, Predicate<Character> extraDelimiterTest) 903 { 904 LV l = new LV(srcStr, sPos, ePos, token.length()); 905 int tokenLen = token.length(); 906 907 for (int i=l.start; i < l.end; i++) 908 909 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 910 && ( (i==0) 911 || Character.isWhitespace(srcStr.charAt(i-1)) 912 || extraDelimiterTest.test(srcStr.charAt(i-1))) 913 && ( ((i + tokenLen) == srcStr.length()) 914 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 915 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 916 ) 917 return i; 918 919 return -1; 920 } 921 922 /** 923 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 924 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 925 * {@code 'srcStr'} where the match occured. 926 * 927 * <BR /><BR /><DIV CLASS=JDHint> 928 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 929 * </DIV> 930 * 931 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 932 * 933 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 934 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 935 * 936 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 937 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 938 * 939 * @param token This is the sub-string that will be 'searched-for' in input-parameter 940 * {@code String 'srcStr'}. 941 * 942 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 943 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 944 * 945 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 946 * 947 * @throws StringIndexOutOfBoundsException 948 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 949 */ 950 public static int first_CI(String srcStr, int sPos, int ePos, String token) 951 { 952 LV l = new LV(srcStr, sPos, ePos, token.length()); 953 int tokenLen = token.length(); 954 955 for (int i=l.start; i < l.end; i++) 956 957 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 958 && ( (i==0) 959 || Character.isWhitespace(srcStr.charAt(i-1))) 960 && ( ((i + tokenLen) == srcStr.length()) 961 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 962 ) 963 return i; 964 965 return -1; 966 } 967 968 /** 969 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 970 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 971 * {@code 'srcStr'} where the match occured. 972 * 973 * <BR /><BR /><DIV CLASS=JDHint> 974 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 975 * </DIV> 976 * 977 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 978 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 979 * 980 * @param c This is the character that will be 'searched-for' in input-parameter 981 * {@code String 'srcStr'}. 982 * 983 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 984 * 985 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 986 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 987 * 988 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 989 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 990 */ 991 public static int first_CI(String srcStr, char c, Predicate<Character> extraDelimiterTest) 992 { 993 LV l = new LV(srcStr, 0, -1); 994 995 c = Character.toLowerCase(c); 996 997 for (int i=l.start; i < l.end; i++) 998 999 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 1000 && ( (i==0) 1001 || Character.isWhitespace(srcStr.charAt(i-1)) 1002 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1003 && ( ((i+1) == srcStr.length()) 1004 || Character.isWhitespace(srcStr.charAt(i+1)) 1005 || extraDelimiterTest.test(srcStr.charAt(i+1))) 1006 ) 1007 return i; 1008 1009 return -1; 1010 } 1011 1012 /** 1013 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 1014 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1015 * {@code 'srcStr'} where the match occured. 1016 * 1017 * <BR /><BR /><DIV CLASS=JDHint> 1018 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1019 * </DIV> 1020 * 1021 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1022 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1023 * 1024 * @param c This is the character that will be 'searched-for' in input-parameter 1025 * {@code String 'srcStr'}. 1026 * 1027 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1028 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1029 * 1030 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1031 */ 1032 public static int first_CI(String srcStr, char c) 1033 { 1034 LV l = new LV(srcStr, 0, -1); 1035 1036 c = Character.toLowerCase(c); 1037 1038 for (int i=l.start; i < l.end; i++) 1039 1040 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 1041 && ( (i==0) 1042 || Character.isWhitespace(srcStr.charAt(i-1))) 1043 && ( ((i+1) == srcStr.length()) 1044 || Character.isWhitespace(srcStr.charAt(i+1))) 1045 ) 1046 return i; 1047 1048 return -1; 1049 } 1050 1051 /** 1052 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 1053 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1054 * {@code 'srcStr'} where the match occured. 1055 * 1056 * <BR /><BR /><DIV CLASS=JDHint> 1057 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1058 * </DIV> 1059 * 1060 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1061 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1062 * 1063 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1064 * {@code String 'srcStr'}. 1065 * 1066 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 1067 * 1068 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1069 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1070 * 1071 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1072 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1073 */ 1074 public static int first_CI 1075 (String srcStr, String token, Predicate<Character> extraDelimiterTest) 1076 { 1077 LV l = new LV(srcStr, 0, -1, token.length()); 1078 int tokenLen = token.length(); 1079 1080 for (int i=l.start; i < l.end; i++) 1081 1082 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 1083 && ( (i==0) 1084 || Character.isWhitespace(srcStr.charAt(i-1)) 1085 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1086 && ( ((i + tokenLen) == srcStr.length()) 1087 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1088 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1089 ) 1090 return i; 1091 1092 return -1; 1093 } 1094 1095 /** 1096 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 1097 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1098 * {@code 'srcStr'} where the match occured. 1099 * 1100 * <BR /><BR /><DIV CLASS=JDHint> 1101 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1102 * </DIV> 1103 * 1104 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1105 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1106 * 1107 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1108 * {@code String 'srcStr'}. 1109 * 1110 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1111 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1112 * 1113 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1114 */ 1115 public static int first_CI(String srcStr, String token) 1116 { 1117 LV l = new LV(srcStr, 0, -1, token.length()); 1118 int tokenLen = token.length(); 1119 1120 for (int i=l.start; i < l.end; i++) 1121 1122 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 1123 && ( (i==0) 1124 || Character.isWhitespace(srcStr.charAt(i-1))) 1125 && ( ((i + tokenLen) == srcStr.length()) 1126 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 1127 ) 1128 return i; 1129 1130 return -1; 1131 } 1132 1133 /** 1134 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 1135 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1136 * {@code 'srcStr'} where the match occured. 1137 * 1138 * <BR /><BR /><DIV CLASS=JDHint> 1139 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1140 * </DIV> 1141 * 1142 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1143 * 1144 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1145 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1146 * 1147 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1148 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1149 * 1150 * @param c This is the character that will be 'searched-for' in input-parameter 1151 * {@code String 'srcStr'}. 1152 * 1153 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 1154 * 1155 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1156 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1157 * 1158 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1159 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1160 * 1161 * @throws StringIndexOutOfBoundsException 1162 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1163 */ 1164 public static int first 1165 (String srcStr, int sPos, int ePos, char c, Predicate<Character> extraDelimiterTest) 1166 { 1167 LV l = new LV(srcStr, sPos, ePos); 1168 1169 for (int i=l.start; i < l.end; i++) 1170 1171 if ( (c == srcStr.charAt(i)) 1172 && ( (i==0) 1173 || Character.isWhitespace(srcStr.charAt(i-1)) 1174 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1175 && ( ((i+1) == srcStr.length()) 1176 || Character.isWhitespace(srcStr.charAt(i+1)) 1177 || extraDelimiterTest.test(srcStr.charAt(i+1))) 1178 ) 1179 return i; 1180 1181 return -1; 1182 } 1183 1184 /** 1185 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 1186 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1187 * {@code 'srcStr'} where the match occured. 1188 * 1189 * <BR /><BR /><DIV CLASS=JDHint> 1190 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1191 * </DIV> 1192 * 1193 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1194 * 1195 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1196 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1197 * 1198 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1199 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1200 * 1201 * @param c This is the character that will be 'searched-for' in input-parameter 1202 * {@code String 'srcStr'}. 1203 * 1204 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1205 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1206 * 1207 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1208 * 1209 * @throws StringIndexOutOfBoundsException 1210 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1211 */ 1212 public static int first(String srcStr, int sPos, int ePos, char c) 1213 { 1214 LV l = new LV(srcStr, sPos, ePos); 1215 1216 for (int i=l.start; i < l.end; i++) 1217 1218 if ( (c == srcStr.charAt(i)) 1219 && ( (i==0) 1220 || Character.isWhitespace(srcStr.charAt(i-1))) 1221 && ( ((i+1) == srcStr.length()) 1222 || Character.isWhitespace(srcStr.charAt(i+1))) 1223 ) 1224 return i; 1225 1226 return -1; 1227 } 1228 1229 /** 1230 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 1231 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1232 * {@code 'srcStr'} where the match occured. 1233 * 1234 * <BR /><BR /><DIV CLASS=JDHint> 1235 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1236 * </DIV> 1237 * 1238 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1239 * 1240 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1241 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1242 * 1243 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1244 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1245 * 1246 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1247 * {@code String 'srcStr'}. 1248 * 1249 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 1250 * 1251 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1252 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1253 * 1254 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1255 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1256 * 1257 * @throws StringIndexOutOfBoundsException 1258 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1259 */ 1260 public static int first 1261 (String srcStr, int sPos, int ePos, String token, Predicate<Character> extraDelimiterTest) 1262 { 1263 LV l = new LV(srcStr, sPos, ePos, token.length()); 1264 int tokenLen = token.length(); 1265 1266 for (int i=l.start; i < l.end; i++) 1267 1268 if ( srcStr.regionMatches(i, token, 0, tokenLen) 1269 && ( (i==0) 1270 || Character.isWhitespace(srcStr.charAt(i-1)) 1271 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1272 && ( ((i + tokenLen) == srcStr.length()) 1273 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1274 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1275 ) 1276 return i; 1277 1278 return -1; 1279 } 1280 1281 /** 1282 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 1283 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1284 * {@code 'srcStr'} where the match occured. 1285 * 1286 * <BR /><BR /><DIV CLASS=JDHint> 1287 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1288 * </DIV> 1289 * 1290 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1291 * 1292 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1293 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1294 * 1295 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1296 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1297 * 1298 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1299 * {@code String 'srcStr'}. 1300 * 1301 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1302 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1303 * 1304 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1305 * 1306 * @throws StringIndexOutOfBoundsException 1307 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1308 */ 1309 public static int first(String srcStr, int sPos, int ePos, String token) 1310 { 1311 LV l = new LV(srcStr, sPos, ePos, token.length()); 1312 int tokenLen = token.length(); 1313 1314 for (int i=l.start; i < l.end; i++) 1315 1316 if ( srcStr.regionMatches(i, token, 0, tokenLen) 1317 && ( (i==0) 1318 || Character.isWhitespace(srcStr.charAt(i-1))) 1319 && ( ((i + tokenLen) == srcStr.length()) 1320 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 1321 ) 1322 return i; 1323 1324 return -1; 1325 } 1326 1327 /** 1328 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 1329 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1330 * {@code 'srcStr'} where the match occured. 1331 * 1332 * <BR /><BR /><DIV CLASS=JDHint> 1333 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1334 * </DIV> 1335 * 1336 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1337 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1338 * 1339 * @param c This is the character that will be 'searched-for' in input-parameter 1340 * {@code String 'srcStr'}. 1341 * 1342 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 1343 * 1344 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1345 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1346 * 1347 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1348 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1349 */ 1350 public static int first(String srcStr, char c, Predicate<Character> extraDelimiterTest) 1351 { 1352 LV l = new LV(srcStr, 0, -1); 1353 1354 for (int i=l.start; i < l.end; i++) 1355 1356 if ( (c == srcStr.charAt(i)) 1357 && ( (i==0) 1358 || Character.isWhitespace(srcStr.charAt(i-1)) 1359 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1360 && ( ((i+1) == srcStr.length()) 1361 || Character.isWhitespace(srcStr.charAt(i+1)) 1362 || extraDelimiterTest.test(srcStr.charAt(i+1))) 1363 ) 1364 return i; 1365 1366 return -1; 1367 } 1368 1369 /** 1370 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 1371 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1372 * {@code 'srcStr'} where the match occured. 1373 * 1374 * <BR /><BR /><DIV CLASS=JDHint> 1375 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1376 * </DIV> 1377 * 1378 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1379 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1380 * 1381 * @param c This is the character that will be 'searched-for' in input-parameter 1382 * {@code String 'srcStr'}. 1383 * 1384 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1385 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1386 * 1387 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1388 */ 1389 public static int first(String srcStr, char c) 1390 { 1391 LV l = new LV(srcStr, 0, -1); 1392 1393 for (int i=l.start; i < l.end; i++) 1394 1395 if ( (c == srcStr.charAt(i)) 1396 && ( (i==0) 1397 || Character.isWhitespace(srcStr.charAt(i-1))) 1398 && ( ((i+1) == srcStr.length()) 1399 || Character.isWhitespace(srcStr.charAt(i+1))) 1400 ) 1401 return i; 1402 1403 return -1; 1404 } 1405 1406 /** 1407 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 1408 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1409 * {@code 'srcStr'} where the match occured. 1410 * 1411 * <BR /><BR /><DIV CLASS=JDHint> 1412 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1413 * </DIV> 1414 * 1415 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1416 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1417 * 1418 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1419 * {@code String 'srcStr'}. 1420 * 1421 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 1422 * 1423 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1424 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1425 * 1426 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1427 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1428 */ 1429 public static int first 1430 (String srcStr, String token, Predicate<Character> extraDelimiterTest) 1431 { 1432 LV l = new LV(srcStr, 0, -1, token.length()); 1433 int tokenLen = token.length(); 1434 1435 for (int i=l.start; i < l.end; i++) 1436 1437 if ( srcStr.regionMatches(i, token, 0, tokenLen) 1438 && ( (i==0) 1439 || Character.isWhitespace(srcStr.charAt(i-1)) 1440 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1441 && ( ((i + tokenLen) == srcStr.length()) 1442 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1443 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1444 ) 1445 return i; 1446 1447 return -1; 1448 } 1449 1450 /** 1451 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 1452 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1453 * {@code 'srcStr'} where the match occured. 1454 * 1455 * <BR /><BR /><DIV CLASS=JDHint> 1456 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1457 * </DIV> 1458 * 1459 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1460 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1461 * 1462 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1463 * {@code String 'srcStr'}. 1464 * 1465 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>first</B> 1466 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1467 * 1468 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1469 */ 1470 public static int first(String srcStr, String token) 1471 { 1472 LV l = new LV(srcStr, 0, -1, token.length()); 1473 int tokenLen = token.length(); 1474 1475 for (int i=l.start; i < l.end; i++) 1476 1477 if ( srcStr.regionMatches(i, token, 0, tokenLen) 1478 && ( (i==0) 1479 || Character.isWhitespace(srcStr.charAt(i-1))) 1480 && ( ((i + tokenLen) == srcStr.length()) 1481 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 1482 ) 1483 return i; 1484 1485 return -1; 1486 } 1487 1488 /** 1489 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 1490 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1491 * {@code 'srcStr'} where the match occured. 1492 * 1493 * <BR /><BR /><DIV CLASS=JDHint> 1494 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1495 * </DIV> 1496 * 1497 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1498 * 1499 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1500 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1501 * 1502 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1503 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1504 * 1505 * @param c This is the character that will be 'searched-for' in input-parameter 1506 * {@code String 'srcStr'}. 1507 * 1508 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 1509 * 1510 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1511 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1512 * 1513 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1514 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1515 * 1516 * @throws StringIndexOutOfBoundsException 1517 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1518 */ 1519 public static int last_CI 1520 (String srcStr, int sPos, int ePos, char c, Predicate<Character> extraDelimiterTest) 1521 { 1522 LV l = new LV(srcStr, sPos, ePos); 1523 1524 c = Character.toLowerCase(c); 1525 1526 for (int i=(l.end-1); i >= l.start; i--) 1527 1528 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 1529 && ( (i==0) 1530 || Character.isWhitespace(srcStr.charAt(i-1)) 1531 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1532 && ( ((i+1) == srcStr.length()) 1533 || Character.isWhitespace(srcStr.charAt(i+1)) 1534 || extraDelimiterTest.test(srcStr.charAt(i+1))) 1535 ) 1536 return i; 1537 1538 return -1; 1539 } 1540 1541 /** 1542 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 1543 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1544 * {@code 'srcStr'} where the match occured. 1545 * 1546 * <BR /><BR /><DIV CLASS=JDHint> 1547 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1548 * </DIV> 1549 * 1550 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1551 * 1552 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1553 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1554 * 1555 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1556 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1557 * 1558 * @param c This is the character that will be 'searched-for' in input-parameter 1559 * {@code String 'srcStr'}. 1560 * 1561 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1562 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1563 * 1564 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1565 * 1566 * @throws StringIndexOutOfBoundsException 1567 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1568 */ 1569 public static int last_CI(String srcStr, int sPos, int ePos, char c) 1570 { 1571 LV l = new LV(srcStr, sPos, ePos); 1572 1573 c = Character.toLowerCase(c); 1574 1575 for (int i=(l.end-1); i >= l.start; i--) 1576 1577 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 1578 && ( (i==0) 1579 || Character.isWhitespace(srcStr.charAt(i-1))) 1580 && ( ((i+1) == srcStr.length()) 1581 || Character.isWhitespace(srcStr.charAt(i+1))) 1582 ) 1583 return i; 1584 1585 return -1; 1586 } 1587 1588 /** 1589 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 1590 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1591 * {@code 'srcStr'} where the match occured. 1592 * 1593 * <BR /><BR /><DIV CLASS=JDHint> 1594 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1595 * </DIV> 1596 * 1597 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1598 * 1599 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1600 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1601 * 1602 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1603 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1604 * 1605 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1606 * {@code String 'srcStr'}. 1607 * 1608 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 1609 * 1610 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1611 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1612 * 1613 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1614 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1615 * 1616 * @throws StringIndexOutOfBoundsException 1617 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1618 */ 1619 public static int last_CI 1620 (String srcStr, int sPos, int ePos, String token, Predicate<Character> extraDelimiterTest) 1621 { 1622 LV l = new LV(srcStr, sPos, ePos, token.length()); 1623 int tokenLen = token.length(); 1624 1625 for (int i=(l.end-1); i >= l.start; i--) 1626 1627 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 1628 && ( (i==0) 1629 || Character.isWhitespace(srcStr.charAt(i-1)) 1630 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1631 && ( ((i + tokenLen) == srcStr.length()) 1632 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1633 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1634 ) 1635 return i; 1636 1637 return -1; 1638 } 1639 1640 /** 1641 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 1642 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1643 * {@code 'srcStr'} where the match occured. 1644 * 1645 * <BR /><BR /><DIV CLASS=JDHint> 1646 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1647 * </DIV> 1648 * 1649 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1650 * 1651 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1652 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1653 * 1654 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1655 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1656 * 1657 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1658 * {@code String 'srcStr'}. 1659 * 1660 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1661 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1662 * 1663 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1664 * 1665 * @throws StringIndexOutOfBoundsException 1666 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1667 */ 1668 public static int last_CI(String srcStr, int sPos, int ePos, String token) 1669 { 1670 LV l = new LV(srcStr, sPos, ePos, token.length()); 1671 int tokenLen = token.length(); 1672 1673 for (int i=(l.end-1); i >= l.start; i--) 1674 1675 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 1676 && ( (i==0) 1677 || Character.isWhitespace(srcStr.charAt(i-1))) 1678 && ( ((i + tokenLen) == srcStr.length()) 1679 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 1680 ) 1681 return i; 1682 1683 return -1; 1684 } 1685 1686 /** 1687 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 1688 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1689 * {@code 'srcStr'} where the match occured. 1690 * 1691 * <BR /><BR /><DIV CLASS=JDHint> 1692 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1693 * </DIV> 1694 * 1695 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1696 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1697 * 1698 * @param c This is the character that will be 'searched-for' in input-parameter 1699 * {@code String 'srcStr'}. 1700 * 1701 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 1702 * 1703 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1704 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1705 * 1706 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1707 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1708 */ 1709 public static int last_CI(String srcStr, char c, Predicate<Character> extraDelimiterTest) 1710 { 1711 LV l = new LV(srcStr, 0, -1); 1712 1713 c = Character.toLowerCase(c); 1714 1715 for (int i=(l.end-1); i >= l.start; i--) 1716 1717 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 1718 && ( (i==0) 1719 || Character.isWhitespace(srcStr.charAt(i-1)) 1720 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1721 && ( ((i+1) == srcStr.length()) 1722 || Character.isWhitespace(srcStr.charAt(i+1)) 1723 || extraDelimiterTest.test(srcStr.charAt(i+1))) 1724 ) 1725 return i; 1726 1727 return -1; 1728 } 1729 1730 /** 1731 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 1732 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1733 * {@code 'srcStr'} where the match occured. 1734 * 1735 * <BR /><BR /><DIV CLASS=JDHint> 1736 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1737 * </DIV> 1738 * 1739 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1740 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1741 * 1742 * @param c This is the character that will be 'searched-for' in input-parameter 1743 * {@code String 'srcStr'}. 1744 * 1745 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1746 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1747 * 1748 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1749 */ 1750 public static int last_CI(String srcStr, char c) 1751 { 1752 LV l = new LV(srcStr, 0, -1); 1753 1754 c = Character.toLowerCase(c); 1755 1756 for (int i=(l.end-1); i >= l.start; i--) 1757 1758 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 1759 && ( (i==0) 1760 || Character.isWhitespace(srcStr.charAt(i-1))) 1761 && ( ((i+1) == srcStr.length()) 1762 || Character.isWhitespace(srcStr.charAt(i+1))) 1763 ) 1764 return i; 1765 1766 return -1; 1767 } 1768 1769 /** 1770 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 1771 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1772 * {@code 'srcStr'} where the match occured. 1773 * 1774 * <BR /><BR /><DIV CLASS=JDHint> 1775 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1776 * </DIV> 1777 * 1778 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1779 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1780 * 1781 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1782 * {@code String 'srcStr'}. 1783 * 1784 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 1785 * 1786 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1787 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1788 * 1789 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1790 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1791 */ 1792 public static int last_CI 1793 (String srcStr, String token, Predicate<Character> extraDelimiterTest) 1794 { 1795 LV l = new LV(srcStr, 0, -1, token.length()); 1796 int tokenLen = token.length(); 1797 1798 for (int i=(l.end-1); i >= l.start; i--) 1799 1800 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 1801 && ( (i==0) 1802 || Character.isWhitespace(srcStr.charAt(i-1)) 1803 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1804 && ( ((i + tokenLen) == srcStr.length()) 1805 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1806 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1807 ) 1808 return i; 1809 1810 return -1; 1811 } 1812 1813 /** 1814 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 1815 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1816 * {@code 'srcStr'} where the match occured. 1817 * 1818 * <BR /><BR /><DIV CLASS=JDHint> 1819 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 1820 * </DIV> 1821 * 1822 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1823 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1824 * 1825 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1826 * {@code String 'srcStr'}. 1827 * 1828 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1829 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1830 * 1831 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1832 */ 1833 public static int last_CI(String srcStr, String token) 1834 { 1835 LV l = new LV(srcStr, 0, -1, token.length()); 1836 int tokenLen = token.length(); 1837 1838 for (int i=(l.end-1); i >= l.start; i--) 1839 1840 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 1841 && ( (i==0) 1842 || Character.isWhitespace(srcStr.charAt(i-1))) 1843 && ( ((i + tokenLen) == srcStr.length()) 1844 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 1845 ) 1846 return i; 1847 1848 return -1; 1849 } 1850 1851 /** 1852 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 1853 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1854 * {@code 'srcStr'} where the match occured. 1855 * 1856 * <BR /><BR /><DIV CLASS=JDHint> 1857 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1858 * </DIV> 1859 * 1860 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1861 * 1862 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1863 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1864 * 1865 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1866 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1867 * 1868 * @param c This is the character that will be 'searched-for' in input-parameter 1869 * {@code String 'srcStr'}. 1870 * 1871 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 1872 * 1873 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1874 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1875 * 1876 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1877 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1878 * 1879 * @throws StringIndexOutOfBoundsException 1880 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1881 */ 1882 public static int last 1883 (String srcStr, int sPos, int ePos, char c, Predicate<Character> extraDelimiterTest) 1884 { 1885 LV l = new LV(srcStr, sPos, ePos); 1886 1887 for (int i=(l.end-1); i >= l.start; i--) 1888 1889 if ( (c == srcStr.charAt(i)) 1890 && ( (i==0) 1891 || Character.isWhitespace(srcStr.charAt(i-1)) 1892 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1893 && ( ((i+1) == srcStr.length()) 1894 || Character.isWhitespace(srcStr.charAt(i+1)) 1895 || extraDelimiterTest.test(srcStr.charAt(i+1))) 1896 ) 1897 return i; 1898 1899 return -1; 1900 } 1901 1902 /** 1903 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 1904 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 1905 * {@code 'srcStr'} where the match occured. 1906 * 1907 * <BR /><BR /><DIV CLASS=JDHint> 1908 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1909 * </DIV> 1910 * 1911 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1912 * 1913 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1914 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1915 * 1916 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1917 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1918 * 1919 * @param c This is the character that will be 'searched-for' in input-parameter 1920 * {@code String 'srcStr'}. 1921 * 1922 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1923 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 1924 * 1925 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 1926 * 1927 * @throws StringIndexOutOfBoundsException 1928 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1929 */ 1930 public static int last(String srcStr, int sPos, int ePos, char c) 1931 { 1932 LV l = new LV(srcStr, sPos, ePos); 1933 1934 for (int i=(l.end-1); i >= l.start; i--) 1935 1936 if ( (c == srcStr.charAt(i)) 1937 && ( (i==0) 1938 || Character.isWhitespace(srcStr.charAt(i-1))) 1939 && ( ((i+1) == srcStr.length()) 1940 || Character.isWhitespace(srcStr.charAt(i+1))) 1941 ) 1942 return i; 1943 1944 return -1; 1945 } 1946 1947 /** 1948 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 1949 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 1950 * {@code 'srcStr'} where the match occured. 1951 * 1952 * <BR /><BR /><DIV CLASS=JDHint> 1953 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 1954 * </DIV> 1955 * 1956 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 1957 * 1958 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 1959 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 1960 * 1961 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 1962 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 1963 * 1964 * @param token This is the sub-string that will be 'searched-for' in input-parameter 1965 * {@code String 'srcStr'}. 1966 * 1967 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 1968 * 1969 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 1970 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 1971 * 1972 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 1973 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 1974 * 1975 * @throws StringIndexOutOfBoundsException 1976 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 1977 */ 1978 public static int last 1979 (String srcStr, int sPos, int ePos, String token, Predicate<Character> extraDelimiterTest) 1980 { 1981 LV l = new LV(srcStr, sPos, ePos, token.length()); 1982 int tokenLen = token.length(); 1983 1984 for (int i=(l.end-1); i >= l.start; i--) 1985 1986 if ( srcStr.regionMatches(i, token, 0, tokenLen) 1987 && ( (i==0) 1988 || Character.isWhitespace(srcStr.charAt(i-1)) 1989 || extraDelimiterTest.test(srcStr.charAt(i-1))) 1990 && ( ((i + tokenLen) == srcStr.length()) 1991 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 1992 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 1993 ) 1994 return i; 1995 1996 return -1; 1997 } 1998 1999 /** 2000 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 2001 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2002 * {@code 'srcStr'} where the match occured. 2003 * 2004 * <BR /><BR /><DIV CLASS=JDHint> 2005 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2006 * </DIV> 2007 * 2008 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2009 * 2010 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2011 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2012 * 2013 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2014 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2015 * 2016 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2017 * {@code String 'srcStr'}. 2018 * 2019 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 2020 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2021 * 2022 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2023 * 2024 * @throws StringIndexOutOfBoundsException 2025 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2026 */ 2027 public static int last(String srcStr, int sPos, int ePos, String token) 2028 { 2029 LV l = new LV(srcStr, sPos, ePos, token.length()); 2030 int tokenLen = token.length(); 2031 2032 for (int i=(l.end-1); i >= l.start; i--) 2033 2034 if ( srcStr.regionMatches(i, token, 0, tokenLen) 2035 && ( (i==0) 2036 || Character.isWhitespace(srcStr.charAt(i-1))) 2037 && ( ((i + tokenLen) == srcStr.length()) 2038 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 2039 ) 2040 return i; 2041 2042 return -1; 2043 } 2044 2045 /** 2046 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 2047 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2048 * {@code 'srcStr'} where the match occured. 2049 * 2050 * <BR /><BR /><DIV CLASS=JDHint> 2051 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2052 * </DIV> 2053 * 2054 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2055 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2056 * 2057 * @param c This is the character that will be 'searched-for' in input-parameter 2058 * {@code String 'srcStr'}. 2059 * 2060 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 2061 * 2062 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 2063 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2064 * 2065 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2066 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2067 */ 2068 public static int last(String srcStr, char c, Predicate<Character> extraDelimiterTest) 2069 { 2070 LV l = new LV(srcStr, 0, -1); 2071 2072 for (int i=(l.end-1); i >= l.start; i--) 2073 2074 if ( (c == srcStr.charAt(i)) 2075 && ( (i==0) 2076 || Character.isWhitespace(srcStr.charAt(i-1)) 2077 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2078 && ( ((i+1) == srcStr.length()) 2079 || Character.isWhitespace(srcStr.charAt(i+1)) 2080 || extraDelimiterTest.test(srcStr.charAt(i+1))) 2081 ) 2082 return i; 2083 2084 return -1; 2085 } 2086 2087 /** 2088 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code char}-parameter 2089 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2090 * {@code 'srcStr'} where the match occured. 2091 * 2092 * <BR /><BR /><DIV CLASS=JDHint> 2093 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2094 * </DIV> 2095 * 2096 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2097 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2098 * 2099 * @param c This is the character that will be 'searched-for' in input-parameter 2100 * {@code String 'srcStr'}. 2101 * 2102 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 2103 * identified <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2104 * 2105 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2106 */ 2107 public static int last(String srcStr, char c) 2108 { 2109 LV l = new LV(srcStr, 0, -1); 2110 2111 for (int i=(l.end-1); i >= l.start; i--) 2112 2113 if ( (c == srcStr.charAt(i)) 2114 && ( (i==0) 2115 || Character.isWhitespace(srcStr.charAt(i-1))) 2116 && ( ((i+1) == srcStr.length()) 2117 || Character.isWhitespace(srcStr.charAt(i+1))) 2118 ) 2119 return i; 2120 2121 return -1; 2122 } 2123 2124 /** 2125 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 2126 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2127 * {@code 'srcStr'} where the match occured. 2128 * 2129 * <BR /><BR /><DIV CLASS=JDHint> 2130 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2131 * </DIV> 2132 * 2133 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2134 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2135 * 2136 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2137 * {@code String 'srcStr'}. 2138 * 2139 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 2140 * 2141 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 2142 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2143 * 2144 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2145 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2146 */ 2147 public static int last 2148 (String srcStr, String token, Predicate<Character> extraDelimiterTest) 2149 { 2150 LV l = new LV(srcStr, 0, -1, token.length()); 2151 int tokenLen = token.length(); 2152 2153 for (int i=(l.end-1); i >= l.start; i--) 2154 2155 if ( srcStr.regionMatches(i, token, 0, tokenLen) 2156 && ( (i==0) 2157 || Character.isWhitespace(srcStr.charAt(i-1)) 2158 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2159 && ( ((i + tokenLen) == srcStr.length()) 2160 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 2161 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 2162 ) 2163 return i; 2164 2165 return -1; 2166 } 2167 2168 /** 2169 * Search for the <B STYLE='color: red'>last</B> {@code token}-match of {@code String}-param 2170 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2171 * {@code 'srcStr'} where the match occured. 2172 * 2173 * <BR /><BR /><DIV CLASS=JDHint> 2174 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2175 * </DIV> 2176 * 2177 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2178 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2179 * 2180 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2181 * {@code String 'srcStr'}. 2182 * 2183 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>last</B> 2184 * identified <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2185 * 2186 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2187 */ 2188 public static int last(String srcStr, String token) 2189 { 2190 LV l = new LV(srcStr, 0, -1, token.length()); 2191 int tokenLen = token.length(); 2192 2193 for (int i=(l.end-1); i >= l.start; i--) 2194 2195 if ( srcStr.regionMatches(i, token, 0, tokenLen) 2196 && ( (i==0) 2197 || Character.isWhitespace(srcStr.charAt(i-1))) 2198 && ( ((i + tokenLen) == srcStr.length()) 2199 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 2200 ) 2201 return i; 2202 2203 return -1; 2204 } 2205 2206 /** 2207 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2208 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2209 * {@code 'srcStr'} where the match occured. 2210 * 2211 * <BR /><BR /><DIV CLASS=JDHint> 2212 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2213 * </DIV> 2214 * 2215 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2216 * 2217 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2218 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2219 * 2220 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2221 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2222 * 2223 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2224 * {@code 'c'} before returning an answer. 2225 * 2226 * @param c This is the character that will be 'searched-for' in input-parameter 2227 * {@code String 'srcStr'}. 2228 * 2229 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 2230 * 2231 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2232 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2233 * 2234 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2235 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2236 * 2237 * @throws StringIndexOutOfBoundsException 2238 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2239 * 2240 * @throws NException If the value of {@code 'n'} is negative, or greater than 2241 * {@code srcStr.length()}, this exception shall throw. 2242 */ 2243 public static int nth_CI 2244 (String srcStr, int sPos, int ePos, int n, char c, Predicate<Character> extraDelimiterTest) 2245 { 2246 NException.check(n, srcStr); 2247 2248 LV l = new LV(srcStr, sPos, ePos); 2249 2250 c = Character.toLowerCase(c); 2251 2252 for (int i=l.start; i < l.end; i++) 2253 2254 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 2255 && ( (i==0) 2256 || Character.isWhitespace(srcStr.charAt(i-1)) 2257 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2258 && ( ((i+1) == srcStr.length()) 2259 || Character.isWhitespace(srcStr.charAt(i+1)) 2260 || extraDelimiterTest.test(srcStr.charAt(i+1))) 2261 ) 2262 if (--n == 0) return i; 2263 2264 return -1; 2265 } 2266 2267 /** 2268 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2269 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2270 * {@code 'srcStr'} where the match occured. 2271 * 2272 * <BR /><BR /><DIV CLASS=JDHint> 2273 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2274 * </DIV> 2275 * 2276 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2277 * 2278 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2279 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2280 * 2281 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2282 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2283 * 2284 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2285 * {@code 'c'} before returning an answer. 2286 * 2287 * @param c This is the character that will be 'searched-for' in input-parameter 2288 * {@code String 'srcStr'}. 2289 * 2290 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2291 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2292 * 2293 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2294 * 2295 * @throws StringIndexOutOfBoundsException 2296 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2297 * 2298 * @throws NException If the value of {@code 'n'} is negative, or greater than 2299 * {@code srcStr.length()}, this exception shall throw. 2300 */ 2301 public static int nth_CI(String srcStr, int sPos, int ePos, int n, char c) 2302 { 2303 NException.check(n, srcStr); 2304 2305 LV l = new LV(srcStr, sPos, ePos); 2306 2307 c = Character.toLowerCase(c); 2308 2309 for (int i=l.start; i < l.end; i++) 2310 2311 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 2312 && ( (i==0) 2313 || Character.isWhitespace(srcStr.charAt(i-1))) 2314 && ( ((i+1) == srcStr.length()) 2315 || Character.isWhitespace(srcStr.charAt(i+1))) 2316 ) 2317 if (--n == 0) return i; 2318 2319 return -1; 2320 } 2321 2322 /** 2323 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2324 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2325 * {@code 'srcStr'} where the match occured. 2326 * 2327 * <BR /><BR /><DIV CLASS=JDHint> 2328 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2329 * </DIV> 2330 * 2331 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2332 * 2333 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2334 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2335 * 2336 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2337 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2338 * 2339 * @param n This is the number of matches to skip when searching for {@code String}-param 2340 * {@code 'token'} before returning an answer. 2341 * 2342 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2343 * {@code String 'srcStr'}. 2344 * 2345 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 2346 * 2347 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2348 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2349 * 2350 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2351 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2352 * 2353 * @throws StringIndexOutOfBoundsException 2354 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2355 * 2356 * @throws NException If the value of {@code 'n'} is negative, or greater than 2357 * {@code srcStr.length()}, this exception shall throw. 2358 */ 2359 public static int nth_CI 2360 (String srcStr, int sPos, int ePos, int n, String token, Predicate<Character> extraDelimiterTest) 2361 { 2362 NException.check(n, srcStr); 2363 2364 LV l = new LV(srcStr, sPos, ePos, token.length()); 2365 int tokenLen = token.length(); 2366 2367 for (int i=l.start; i < l.end; i++) 2368 2369 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 2370 && ( (i==0) 2371 || Character.isWhitespace(srcStr.charAt(i-1)) 2372 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2373 && ( ((i + tokenLen) == srcStr.length()) 2374 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 2375 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 2376 ) 2377 if (--n == 0) return i; 2378 2379 return -1; 2380 } 2381 2382 /** 2383 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2384 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2385 * {@code 'srcStr'} where the match occured. 2386 * 2387 * <BR /><BR /><DIV CLASS=JDHint> 2388 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2389 * </DIV> 2390 * 2391 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2392 * 2393 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2394 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2395 * 2396 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2397 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2398 * 2399 * @param n This is the number of matches to skip when searching for {@code String}-param 2400 * {@code 'token'} before returning an answer. 2401 * 2402 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2403 * {@code String 'srcStr'}. 2404 * 2405 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2406 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2407 * 2408 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2409 * 2410 * @throws StringIndexOutOfBoundsException 2411 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2412 * 2413 * @throws NException If the value of {@code 'n'} is negative, or greater than 2414 * {@code srcStr.length()}, this exception shall throw. 2415 */ 2416 public static int nth_CI(String srcStr, int sPos, int ePos, int n, String token) 2417 { 2418 NException.check(n, srcStr); 2419 2420 LV l = new LV(srcStr, sPos, ePos, token.length()); 2421 int tokenLen = token.length(); 2422 2423 for (int i=l.start; i < l.end; i++) 2424 2425 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 2426 && ( (i==0) 2427 || Character.isWhitespace(srcStr.charAt(i-1))) 2428 && ( ((i + tokenLen) == srcStr.length()) 2429 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 2430 ) 2431 if (--n == 0) return i; 2432 2433 return -1; 2434 } 2435 2436 /** 2437 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2438 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2439 * {@code 'srcStr'} where the match occured. 2440 * 2441 * <BR /><BR /><DIV CLASS=JDHint> 2442 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2443 * </DIV> 2444 * 2445 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2446 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2447 * 2448 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2449 * {@code 'c'} before returning an answer. 2450 * 2451 * @param c This is the character that will be 'searched-for' in input-parameter 2452 * {@code String 'srcStr'}. 2453 * 2454 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 2455 * 2456 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2457 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2458 * 2459 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2460 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2461 * 2462 * @throws NException If the value of {@code 'n'} is negative, or greater than 2463 * {@code srcStr.length()}, this exception shall throw. 2464 */ 2465 public static int nth_CI 2466 (String srcStr, int n, char c, Predicate<Character> extraDelimiterTest) 2467 { 2468 NException.check(n, srcStr); 2469 2470 LV l = new LV(srcStr, 0, -1); 2471 2472 c = Character.toLowerCase(c); 2473 2474 for (int i=l.start; i < l.end; i++) 2475 2476 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 2477 && ( (i==0) 2478 || Character.isWhitespace(srcStr.charAt(i-1)) 2479 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2480 && ( ((i+1) == srcStr.length()) 2481 || Character.isWhitespace(srcStr.charAt(i+1)) 2482 || extraDelimiterTest.test(srcStr.charAt(i+1))) 2483 ) 2484 if (--n == 0) return i; 2485 2486 return -1; 2487 } 2488 2489 /** 2490 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2491 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2492 * {@code 'srcStr'} where the match occured. 2493 * 2494 * <BR /><BR /><DIV CLASS=JDHint> 2495 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2496 * </DIV> 2497 * 2498 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2499 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2500 * 2501 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2502 * {@code 'c'} before returning an answer. 2503 * 2504 * @param c This is the character that will be 'searched-for' in input-parameter 2505 * {@code String 'srcStr'}. 2506 * 2507 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2508 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2509 * 2510 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2511 * 2512 * @throws NException If the value of {@code 'n'} is negative, or greater than 2513 * {@code srcStr.length()}, this exception shall throw. 2514 */ 2515 public static int nth_CI(String srcStr, int n, char c) 2516 { 2517 NException.check(n, srcStr); 2518 2519 LV l = new LV(srcStr, 0, -1); 2520 2521 c = Character.toLowerCase(c); 2522 2523 for (int i=l.start; i < l.end; i++) 2524 2525 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 2526 && ( (i==0) 2527 || Character.isWhitespace(srcStr.charAt(i-1))) 2528 && ( ((i+1) == srcStr.length()) 2529 || Character.isWhitespace(srcStr.charAt(i+1))) 2530 ) 2531 if (--n == 0) return i; 2532 2533 return -1; 2534 } 2535 2536 /** 2537 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2538 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2539 * {@code 'srcStr'} where the match occured. 2540 * 2541 * <BR /><BR /><DIV CLASS=JDHint> 2542 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2543 * </DIV> 2544 * 2545 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2546 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2547 * 2548 * @param n This is the number of matches to skip when searching for {@code String}-param 2549 * {@code 'token'} before returning an answer. 2550 * 2551 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2552 * {@code String 'srcStr'}. 2553 * 2554 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 2555 * 2556 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2557 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2558 * 2559 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2560 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2561 * 2562 * @throws NException If the value of {@code 'n'} is negative, or greater than 2563 * {@code srcStr.length()}, this exception shall throw. 2564 */ 2565 public static int nth_CI 2566 (String srcStr, int n, String token, Predicate<Character> extraDelimiterTest) 2567 { 2568 NException.check(n, srcStr); 2569 2570 LV l = new LV(srcStr, 0, -1, token.length()); 2571 int tokenLen = token.length(); 2572 2573 for (int i=l.start; i < l.end; i++) 2574 2575 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 2576 && ( (i==0) 2577 || Character.isWhitespace(srcStr.charAt(i-1)) 2578 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2579 && ( ((i + tokenLen) == srcStr.length()) 2580 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 2581 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 2582 ) 2583 if (--n == 0) return i; 2584 2585 return -1; 2586 } 2587 2588 /** 2589 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2590 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2591 * {@code 'srcStr'} where the match occured. 2592 * 2593 * <BR /><BR /><DIV CLASS=JDHint> 2594 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 2595 * </DIV> 2596 * 2597 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2598 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2599 * 2600 * @param n This is the number of matches to skip when searching for {@code String}-param 2601 * {@code 'token'} before returning an answer. 2602 * 2603 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2604 * {@code String 'srcStr'}. 2605 * 2606 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2607 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2608 * 2609 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2610 * 2611 * @throws NException If the value of {@code 'n'} is negative, or greater than 2612 * {@code srcStr.length()}, this exception shall throw. 2613 */ 2614 public static int nth_CI(String srcStr, int n, String token) 2615 { 2616 NException.check(n, srcStr); 2617 2618 LV l = new LV(srcStr, 0, -1, token.length()); 2619 int tokenLen = token.length(); 2620 2621 for (int i=l.start; i < l.end; i++) 2622 2623 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 2624 && ( (i==0) 2625 || Character.isWhitespace(srcStr.charAt(i-1))) 2626 && ( ((i + tokenLen) == srcStr.length()) 2627 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 2628 ) 2629 if (--n == 0) return i; 2630 2631 return -1; 2632 } 2633 2634 /** 2635 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2636 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2637 * {@code 'srcStr'} where the match occured. 2638 * 2639 * <BR /><BR /><DIV CLASS=JDHint> 2640 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2641 * </DIV> 2642 * 2643 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2644 * 2645 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2646 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2647 * 2648 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2649 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2650 * 2651 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2652 * {@code 'c'} before returning an answer. 2653 * 2654 * @param c This is the character that will be 'searched-for' in input-parameter 2655 * {@code String 'srcStr'}. 2656 * 2657 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 2658 * 2659 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2660 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2661 * 2662 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2663 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2664 * 2665 * @throws StringIndexOutOfBoundsException 2666 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2667 * 2668 * @throws NException If the value of {@code 'n'} is negative, or greater than 2669 * {@code srcStr.length()}, this exception shall throw. 2670 */ 2671 public static int nth 2672 (String srcStr, int sPos, int ePos, int n, char c, Predicate<Character> extraDelimiterTest) 2673 { 2674 NException.check(n, srcStr); 2675 2676 LV l = new LV(srcStr, sPos, ePos); 2677 2678 for (int i=l.start; i < l.end; i++) 2679 2680 if ( (c == srcStr.charAt(i)) 2681 && ( (i==0) 2682 || Character.isWhitespace(srcStr.charAt(i-1)) 2683 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2684 && ( ((i+1) == srcStr.length()) 2685 || Character.isWhitespace(srcStr.charAt(i+1)) 2686 || extraDelimiterTest.test(srcStr.charAt(i+1))) 2687 ) 2688 if (--n == 0) return i; 2689 2690 return -1; 2691 } 2692 2693 /** 2694 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2695 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2696 * {@code 'srcStr'} where the match occured. 2697 * 2698 * <BR /><BR /><DIV CLASS=JDHint> 2699 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2700 * </DIV> 2701 * 2702 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2703 * 2704 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2705 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2706 * 2707 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2708 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2709 * 2710 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2711 * {@code 'c'} before returning an answer. 2712 * 2713 * @param c This is the character that will be 'searched-for' in input-parameter 2714 * {@code String 'srcStr'}. 2715 * 2716 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2717 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2718 * 2719 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2720 * 2721 * @throws StringIndexOutOfBoundsException 2722 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2723 * 2724 * @throws NException If the value of {@code 'n'} is negative, or greater than 2725 * {@code srcStr.length()}, this exception shall throw. 2726 */ 2727 public static int nth(String srcStr, int sPos, int ePos, int n, char c) 2728 { 2729 NException.check(n, srcStr); 2730 2731 LV l = new LV(srcStr, sPos, ePos); 2732 2733 for (int i=l.start; i < l.end; i++) 2734 2735 if ( (c == srcStr.charAt(i)) 2736 && ( (i==0) 2737 || Character.isWhitespace(srcStr.charAt(i-1))) 2738 && ( ((i+1) == srcStr.length()) 2739 || Character.isWhitespace(srcStr.charAt(i+1))) 2740 ) 2741 if (--n == 0) return i; 2742 2743 return -1; 2744 } 2745 2746 /** 2747 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2748 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2749 * {@code 'srcStr'} where the match occured. 2750 * 2751 * <BR /><BR /><DIV CLASS=JDHint> 2752 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2753 * </DIV> 2754 * 2755 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2756 * 2757 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2758 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2759 * 2760 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2761 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2762 * 2763 * @param n This is the number of matches to skip when searching for {@code String}-param 2764 * {@code 'token'} before returning an answer. 2765 * 2766 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2767 * {@code String 'srcStr'}. 2768 * 2769 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 2770 * 2771 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2772 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2773 * 2774 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2775 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2776 * 2777 * @throws StringIndexOutOfBoundsException 2778 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2779 * 2780 * @throws NException If the value of {@code 'n'} is negative, or greater than 2781 * {@code srcStr.length()}, this exception shall throw. 2782 */ 2783 public static int nth 2784 (String srcStr, int sPos, int ePos, int n, String token, Predicate<Character> extraDelimiterTest) 2785 { 2786 NException.check(n, srcStr); 2787 2788 LV l = new LV(srcStr, sPos, ePos, token.length()); 2789 int tokenLen = token.length(); 2790 2791 for (int i=l.start; i < l.end; i++) 2792 2793 if ( srcStr.regionMatches(i, token, 0, tokenLen) 2794 && ( (i==0) 2795 || Character.isWhitespace(srcStr.charAt(i-1)) 2796 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2797 && ( ((i + tokenLen) == srcStr.length()) 2798 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 2799 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 2800 ) 2801 if (--n == 0) return i; 2802 2803 return -1; 2804 } 2805 2806 /** 2807 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2808 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2809 * {@code 'srcStr'} where the match occured. 2810 * 2811 * <BR /><BR /><DIV CLASS=JDHint> 2812 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2813 * </DIV> 2814 * 2815 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 2816 * 2817 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2818 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2819 * 2820 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 2821 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 2822 * 2823 * @param n This is the number of matches to skip when searching for {@code String}-param 2824 * {@code 'token'} before returning an answer. 2825 * 2826 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2827 * {@code String 'srcStr'}. 2828 * 2829 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2830 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2831 * 2832 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2833 * 2834 * @throws StringIndexOutOfBoundsException 2835 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 2836 * 2837 * @throws NException If the value of {@code 'n'} is negative, or greater than 2838 * {@code srcStr.length()}, this exception shall throw. 2839 */ 2840 public static int nth(String srcStr, int sPos, int ePos, int n, String token) 2841 { 2842 NException.check(n, srcStr); 2843 2844 LV l = new LV(srcStr, sPos, ePos, token.length()); 2845 int tokenLen = token.length(); 2846 2847 for (int i=l.start; i < l.end; i++) 2848 2849 if ( srcStr.regionMatches(i, token, 0, tokenLen) 2850 && ( (i==0) 2851 || Character.isWhitespace(srcStr.charAt(i-1))) 2852 && ( ((i + tokenLen) == srcStr.length()) 2853 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 2854 ) 2855 if (--n == 0) return i; 2856 2857 return -1; 2858 } 2859 2860 /** 2861 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2862 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2863 * {@code 'srcStr'} where the match occured. 2864 * 2865 * <BR /><BR /><DIV CLASS=JDHint> 2866 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2867 * </DIV> 2868 * 2869 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2870 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2871 * 2872 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2873 * {@code 'c'} before returning an answer. 2874 * 2875 * @param c This is the character that will be 'searched-for' in input-parameter 2876 * {@code String 'srcStr'}. 2877 * 2878 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 2879 * 2880 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2881 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2882 * 2883 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2884 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2885 * 2886 * @throws NException If the value of {@code 'n'} is negative, or greater than 2887 * {@code srcStr.length()}, this exception shall throw. 2888 */ 2889 public static int nth 2890 (String srcStr, int n, char c, Predicate<Character> extraDelimiterTest) 2891 { 2892 NException.check(n, srcStr); 2893 2894 LV l = new LV(srcStr, 0, -1); 2895 2896 for (int i=l.start; i < l.end; i++) 2897 2898 if ( (c == srcStr.charAt(i)) 2899 && ( (i==0) 2900 || Character.isWhitespace(srcStr.charAt(i-1)) 2901 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2902 && ( ((i+1) == srcStr.length()) 2903 || Character.isWhitespace(srcStr.charAt(i+1)) 2904 || extraDelimiterTest.test(srcStr.charAt(i+1))) 2905 ) 2906 if (--n == 0) return i; 2907 2908 return -1; 2909 } 2910 2911 /** 2912 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 2913 * {@code 'c'} in {@code 'srcStr'}, and return the integer index-location into 2914 * {@code 'srcStr'} where the match occured. 2915 * 2916 * <BR /><BR /><DIV CLASS=JDHint> 2917 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2918 * </DIV> 2919 * 2920 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2921 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2922 * 2923 * @param n This is the number of matches to skip when searching for {@code char}-parameter 2924 * {@code 'c'} before returning an answer. 2925 * 2926 * @param c This is the character that will be 'searched-for' in input-parameter 2927 * {@code String 'srcStr'}. 2928 * 2929 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2930 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'} 2931 * 2932 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 2933 * 2934 * @throws NException If the value of {@code 'n'} is negative, or greater than 2935 * {@code srcStr.length()}, this exception shall throw. 2936 */ 2937 public static int nth(String srcStr, int n, char c) 2938 { 2939 NException.check(n, srcStr); 2940 2941 LV l = new LV(srcStr, 0, -1); 2942 2943 for (int i=l.start; i < l.end; i++) 2944 2945 if ( (c == srcStr.charAt(i)) 2946 && ( (i==0) 2947 || Character.isWhitespace(srcStr.charAt(i-1))) 2948 && ( ((i+1) == srcStr.length()) 2949 || Character.isWhitespace(srcStr.charAt(i+1))) 2950 ) 2951 if (--n == 0) return i; 2952 2953 return -1; 2954 } 2955 2956 /** 2957 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 2958 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 2959 * {@code 'srcStr'} where the match occured. 2960 * 2961 * <BR /><BR /><DIV CLASS=JDHint> 2962 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 2963 * </DIV> 2964 * 2965 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 2966 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 2967 * 2968 * @param n This is the number of matches to skip when searching for {@code String}-param 2969 * {@code 'token'} before returning an answer. 2970 * 2971 * @param token This is the sub-string that will be 'searched-for' in input-parameter 2972 * {@code String 'srcStr'}. 2973 * 2974 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 2975 * 2976 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 2977 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 2978 * 2979 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 2980 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 2981 * 2982 * @throws NException If the value of {@code 'n'} is negative, or greater than 2983 * {@code srcStr.length()}, this exception shall throw. 2984 */ 2985 public static int nth 2986 (String srcStr, int n, String token, Predicate<Character> extraDelimiterTest) 2987 { 2988 NException.check(n, srcStr); 2989 2990 LV l = new LV(srcStr, 0, -1, token.length()); 2991 int tokenLen = token.length(); 2992 2993 for (int i=l.start; i < l.end; i++) 2994 2995 if ( srcStr.regionMatches(i, token, 0, tokenLen) 2996 && ( (i==0) 2997 || Character.isWhitespace(srcStr.charAt(i-1)) 2998 || extraDelimiterTest.test(srcStr.charAt(i-1))) 2999 && ( ((i + tokenLen) == srcStr.length()) 3000 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 3001 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 3002 ) 3003 if (--n == 0) return i; 3004 3005 return -1; 3006 } 3007 3008 /** 3009 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3010 * {@code 'token'} in {@code 'srcStr'}, and return the integer index-location into 3011 * {@code 'srcStr'} where the match occured. 3012 * 3013 * <BR /><BR /><DIV CLASS=JDHint> 3014 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3015 * </DIV> 3016 * 3017 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3018 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3019 * 3020 * @param n This is the number of matches to skip when searching for {@code String}-param 3021 * {@code 'token'} before returning an answer. 3022 * 3023 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3024 * {@code String 'srcStr'}. 3025 * 3026 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3027 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'} 3028 * 3029 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3030 * 3031 * @throws NException If the value of {@code 'n'} is negative, or greater than 3032 * {@code srcStr.length()}, this exception shall throw. 3033 */ 3034 public static int nth(String srcStr, int n, String token) 3035 { 3036 NException.check(n, srcStr); 3037 3038 LV l = new LV(srcStr, 0, -1, token.length()); 3039 int tokenLen = token.length(); 3040 3041 for (int i=l.start; i < l.end; i++) 3042 3043 if ( srcStr.regionMatches(i, token, 0, tokenLen) 3044 && ( (i==0) 3045 || Character.isWhitespace(srcStr.charAt(i-1))) 3046 && ( ((i + tokenLen) == srcStr.length()) 3047 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 3048 ) 3049 if (--n == 0) return i; 3050 3051 return -1; 3052 } 3053 3054 /** 3055 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3056 * {@code 'c'} but <I>start the search with the last character of the String, and work 3057 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3058 * {@code 'srcStr'} where the match occured. 3059 * 3060 * <BR /><BR /><DIV CLASS=JDHint> 3061 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3062 * </DIV> 3063 * 3064 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3065 * 3066 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3067 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3068 * 3069 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3070 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3071 * 3072 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3073 * {@code 'c'} before returning an answer. 3074 * 3075 * @param c This is the character that will be 'searched-for' in input-parameter 3076 * {@code String 'srcStr'}. 3077 * 3078 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 3079 * 3080 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3081 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3082 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3083 * 3084 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3085 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3086 * 3087 * @throws StringIndexOutOfBoundsException 3088 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3089 * 3090 * @throws NException If the value of {@code 'n'} is negative, or greater than 3091 * {@code srcStr.length()}, this exception shall throw. 3092 */ 3093 public static int nthFromEnd_CI 3094 (String srcStr, int sPos, int ePos, int n, char c, Predicate<Character> extraDelimiterTest) 3095 { 3096 NException.check(n, srcStr); 3097 3098 LV l = new LV(srcStr, sPos, ePos); 3099 3100 c = Character.toLowerCase(c); 3101 3102 for (int i=(l.end-1); i >= l.start; i--) 3103 3104 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 3105 && ( (i==0) 3106 || Character.isWhitespace(srcStr.charAt(i-1)) 3107 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3108 && ( ((i+1) == srcStr.length()) 3109 || Character.isWhitespace(srcStr.charAt(i+1)) 3110 || extraDelimiterTest.test(srcStr.charAt(i+1))) 3111 ) 3112 if (--n == 0) return i; 3113 3114 return -1; 3115 } 3116 3117 /** 3118 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3119 * {@code 'c'} but <I>start the search with the last character of the String, and work 3120 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3121 * {@code 'srcStr'} where the match occured. 3122 * 3123 * <BR /><BR /><DIV CLASS=JDHint> 3124 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3125 * </DIV> 3126 * 3127 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3128 * 3129 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3130 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3131 * 3132 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3133 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3134 * 3135 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3136 * {@code 'c'} before returning an answer. 3137 * 3138 * @param c This is the character that will be 'searched-for' in input-parameter 3139 * {@code String 'srcStr'}. 3140 * 3141 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3142 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3143 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3144 * 3145 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3146 * 3147 * @throws StringIndexOutOfBoundsException 3148 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3149 * 3150 * @throws NException If the value of {@code 'n'} is negative, or greater than 3151 * {@code srcStr.length()}, this exception shall throw. 3152 */ 3153 public static int nthFromEnd_CI(String srcStr, int sPos, int ePos, int n, char c) 3154 { 3155 NException.check(n, srcStr); 3156 3157 LV l = new LV(srcStr, sPos, ePos); 3158 3159 c = Character.toLowerCase(c); 3160 3161 for (int i=(l.end-1); i >= l.start; i--) 3162 3163 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 3164 && ( (i==0) 3165 || Character.isWhitespace(srcStr.charAt(i-1))) 3166 && ( ((i+1) == srcStr.length()) 3167 || Character.isWhitespace(srcStr.charAt(i+1))) 3168 ) 3169 if (--n == 0) return i; 3170 3171 return -1; 3172 } 3173 3174 /** 3175 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3176 * {@code 'token'} but <I>start the search with the last character of the String, and work 3177 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3178 * {@code 'srcStr'} where the match occured. 3179 * 3180 * <BR /><BR /><DIV CLASS=JDHint> 3181 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3182 * </DIV> 3183 * 3184 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3185 * 3186 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3187 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3188 * 3189 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3190 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3191 * 3192 * @param n This is the number of matches to skip when searching for {@code String}-param 3193 * {@code 'token'} before returning an answer. 3194 * 3195 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3196 * {@code String 'srcStr'}. 3197 * 3198 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 3199 * 3200 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3201 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3202 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3203 * 3204 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3205 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3206 * 3207 * @throws StringIndexOutOfBoundsException 3208 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3209 * 3210 * @throws NException If the value of {@code 'n'} is negative, or greater than 3211 * {@code srcStr.length()}, this exception shall throw. 3212 */ 3213 public static int nthFromEnd_CI 3214 (String srcStr, int sPos, int ePos, int n, String token, Predicate<Character> extraDelimiterTest) 3215 { 3216 NException.check(n, srcStr); 3217 3218 LV l = new LV(srcStr, sPos, ePos, token.length()); 3219 int tokenLen = token.length(); 3220 3221 for (int i=(l.end-1); i >= l.start; i--) 3222 3223 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 3224 && ( (i==0) 3225 || Character.isWhitespace(srcStr.charAt(i-1)) 3226 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3227 && ( ((i + tokenLen) == srcStr.length()) 3228 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 3229 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 3230 ) 3231 if (--n == 0) return i; 3232 3233 return -1; 3234 } 3235 3236 /** 3237 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3238 * {@code 'token'} but <I>start the search with the last character of the String, and work 3239 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3240 * {@code 'srcStr'} where the match occured. 3241 * 3242 * <BR /><BR /><DIV CLASS=JDHint> 3243 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3244 * </DIV> 3245 * 3246 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3247 * 3248 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3249 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3250 * 3251 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3252 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3253 * 3254 * @param n This is the number of matches to skip when searching for {@code String}-param 3255 * {@code 'token'} before returning an answer. 3256 * 3257 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3258 * {@code String 'srcStr'}. 3259 * 3260 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3261 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3262 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3263 * 3264 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3265 * 3266 * @throws StringIndexOutOfBoundsException 3267 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3268 * 3269 * @throws NException If the value of {@code 'n'} is negative, or greater than 3270 * {@code srcStr.length()}, this exception shall throw. 3271 */ 3272 public static int nthFromEnd_CI(String srcStr, int sPos, int ePos, int n, String token) 3273 { 3274 NException.check(n, srcStr); 3275 3276 LV l = new LV(srcStr, sPos, ePos, token.length()); 3277 int tokenLen = token.length(); 3278 3279 for (int i=(l.end-1); i >= l.start; i--) 3280 3281 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 3282 && ( (i==0) 3283 || Character.isWhitespace(srcStr.charAt(i-1))) 3284 && ( ((i + tokenLen) == srcStr.length()) 3285 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 3286 ) 3287 if (--n == 0) return i; 3288 3289 return -1; 3290 } 3291 3292 /** 3293 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3294 * {@code 'c'} but <I>start the search with the last character of the String, and work 3295 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3296 * {@code 'srcStr'} where the match occured. 3297 * 3298 * <BR /><BR /><DIV CLASS=JDHint> 3299 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3300 * </DIV> 3301 * 3302 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3303 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3304 * 3305 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3306 * {@code 'c'} before returning an answer. 3307 * 3308 * @param c This is the character that will be 'searched-for' in input-parameter 3309 * {@code String 'srcStr'}. 3310 * 3311 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 3312 * 3313 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3314 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3315 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3316 * 3317 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3318 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3319 * 3320 * @throws NException If the value of {@code 'n'} is negative, or greater than 3321 * {@code srcStr.length()}, this exception shall throw. 3322 */ 3323 public static int nthFromEnd_CI 3324 (String srcStr, int n, char c, Predicate<Character> extraDelimiterTest) 3325 { 3326 NException.check(n, srcStr); 3327 3328 LV l = new LV(srcStr, 0, -1); 3329 3330 c = Character.toLowerCase(c); 3331 3332 for (int i=(l.end-1); i >= l.start; i--) 3333 3334 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 3335 && ( (i==0) 3336 || Character.isWhitespace(srcStr.charAt(i-1)) 3337 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3338 && ( ((i+1) == srcStr.length()) 3339 || Character.isWhitespace(srcStr.charAt(i+1)) 3340 || extraDelimiterTest.test(srcStr.charAt(i+1))) 3341 ) 3342 if (--n == 0) return i; 3343 3344 return -1; 3345 } 3346 3347 /** 3348 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3349 * {@code 'c'} but <I>start the search with the last character of the String, and work 3350 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3351 * {@code 'srcStr'} where the match occured. 3352 * 3353 * <BR /><BR /><DIV CLASS=JDHint> 3354 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3355 * </DIV> 3356 * 3357 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3358 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3359 * 3360 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3361 * {@code 'c'} before returning an answer. 3362 * 3363 * @param c This is the character that will be 'searched-for' in input-parameter 3364 * {@code String 'srcStr'}. 3365 * 3366 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3367 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3368 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3369 * 3370 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3371 * 3372 * @throws NException If the value of {@code 'n'} is negative, or greater than 3373 * {@code srcStr.length()}, this exception shall throw. 3374 */ 3375 public static int nthFromEnd_CI(String srcStr, int n, char c) 3376 { 3377 NException.check(n, srcStr); 3378 3379 LV l = new LV(srcStr, 0, -1); 3380 3381 c = Character.toLowerCase(c); 3382 3383 for (int i=(l.end-1); i >= l.start; i--) 3384 3385 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 3386 && ( (i==0) 3387 || Character.isWhitespace(srcStr.charAt(i-1))) 3388 && ( ((i+1) == srcStr.length()) 3389 || Character.isWhitespace(srcStr.charAt(i+1))) 3390 ) 3391 if (--n == 0) return i; 3392 3393 return -1; 3394 } 3395 3396 /** 3397 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3398 * {@code 'token'} but <I>start the search with the last character of the String, and work 3399 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3400 * {@code 'srcStr'} where the match occured. 3401 * 3402 * <BR /><BR /><DIV CLASS=JDHint> 3403 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3404 * </DIV> 3405 * 3406 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3407 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3408 * 3409 * @param n This is the number of matches to skip when searching for {@code String}-param 3410 * {@code 'token'} before returning an answer. 3411 * 3412 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3413 * {@code String 'srcStr'}. 3414 * 3415 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 3416 * 3417 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3418 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3419 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3420 * 3421 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3422 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3423 * 3424 * @throws NException If the value of {@code 'n'} is negative, or greater than 3425 * {@code srcStr.length()}, this exception shall throw. 3426 */ 3427 public static int nthFromEnd_CI 3428 (String srcStr, int n, String token, Predicate<Character> extraDelimiterTest) 3429 { 3430 NException.check(n, srcStr); 3431 3432 LV l = new LV(srcStr, 0, -1, token.length()); 3433 int tokenLen = token.length(); 3434 3435 for (int i=(l.end-1); i >= l.start; i--) 3436 3437 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 3438 && ( (i==0) 3439 || Character.isWhitespace(srcStr.charAt(i-1)) 3440 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3441 && ( ((i + tokenLen) == srcStr.length()) 3442 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 3443 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 3444 ) 3445 if (--n == 0) return i; 3446 3447 return -1; 3448 } 3449 3450 /** 3451 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3452 * {@code 'token'} but <I>start the search with the last character of the String, and work 3453 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3454 * {@code 'srcStr'} where the match occured. 3455 * 3456 * <BR /><BR /><DIV CLASS=JDHint> 3457 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3458 * </DIV> 3459 * 3460 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3461 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3462 * 3463 * @param n This is the number of matches to skip when searching for {@code String}-param 3464 * {@code 'token'} before returning an answer. 3465 * 3466 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3467 * {@code String 'srcStr'}. 3468 * 3469 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3470 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3471 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3472 * 3473 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3474 * 3475 * @throws NException If the value of {@code 'n'} is negative, or greater than 3476 * {@code srcStr.length()}, this exception shall throw. 3477 */ 3478 public static int nthFromEnd_CI(String srcStr, int n, String token) 3479 { 3480 NException.check(n, srcStr); 3481 3482 LV l = new LV(srcStr, 0, -1, token.length()); 3483 int tokenLen = token.length(); 3484 3485 for (int i=(l.end-1); i >= l.start; i--) 3486 3487 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 3488 && ( (i==0) 3489 || Character.isWhitespace(srcStr.charAt(i-1))) 3490 && ( ((i + tokenLen) == srcStr.length()) 3491 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 3492 ) 3493 if (--n == 0) return i; 3494 3495 return -1; 3496 } 3497 3498 /** 3499 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3500 * {@code 'c'} but <I>start the search with the last character of the String, and work 3501 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3502 * {@code 'srcStr'} where the match occured. 3503 * 3504 * <BR /><BR /><DIV CLASS=JDHint> 3505 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3506 * </DIV> 3507 * 3508 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3509 * 3510 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3511 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3512 * 3513 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3514 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3515 * 3516 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3517 * {@code 'c'} before returning an answer. 3518 * 3519 * @param c This is the character that will be 'searched-for' in input-parameter 3520 * {@code String 'srcStr'}. 3521 * 3522 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 3523 * 3524 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3525 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3526 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3527 * 3528 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3529 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3530 * 3531 * @throws StringIndexOutOfBoundsException 3532 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3533 * 3534 * @throws NException If the value of {@code 'n'} is negative, or greater than 3535 * {@code srcStr.length()}, this exception shall throw. 3536 */ 3537 public static int nthFromEnd 3538 (String srcStr, int sPos, int ePos, int n, char c, Predicate<Character> extraDelimiterTest) 3539 { 3540 NException.check(n, srcStr); 3541 3542 LV l = new LV(srcStr, sPos, ePos); 3543 3544 for (int i=(l.end-1); i >= l.start; i--) 3545 3546 if ( (c == srcStr.charAt(i)) 3547 && ( (i==0) 3548 || Character.isWhitespace(srcStr.charAt(i-1)) 3549 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3550 && ( ((i+1) == srcStr.length()) 3551 || Character.isWhitespace(srcStr.charAt(i+1)) 3552 || extraDelimiterTest.test(srcStr.charAt(i+1))) 3553 ) 3554 if (--n == 0) return i; 3555 3556 return -1; 3557 } 3558 3559 /** 3560 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3561 * {@code 'c'} but <I>start the search with the last character of the String, and work 3562 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3563 * {@code 'srcStr'} where the match occured. 3564 * 3565 * <BR /><BR /><DIV CLASS=JDHint> 3566 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3567 * </DIV> 3568 * 3569 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3570 * 3571 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3572 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3573 * 3574 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3575 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3576 * 3577 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3578 * {@code 'c'} before returning an answer. 3579 * 3580 * @param c This is the character that will be 'searched-for' in input-parameter 3581 * {@code String 'srcStr'}. 3582 * 3583 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3584 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3585 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3586 * 3587 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3588 * 3589 * @throws StringIndexOutOfBoundsException 3590 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3591 * 3592 * @throws NException If the value of {@code 'n'} is negative, or greater than 3593 * {@code srcStr.length()}, this exception shall throw. 3594 */ 3595 public static int nthFromEnd(String srcStr, int sPos, int ePos, int n, char c) 3596 { 3597 NException.check(n, srcStr); 3598 3599 LV l = new LV(srcStr, sPos, ePos); 3600 3601 for (int i=(l.end-1); i >= l.start; i--) 3602 3603 if ( (c == srcStr.charAt(i)) 3604 && ( (i==0) 3605 || Character.isWhitespace(srcStr.charAt(i-1))) 3606 && ( ((i+1) == srcStr.length()) 3607 || Character.isWhitespace(srcStr.charAt(i+1))) 3608 ) 3609 if (--n == 0) return i; 3610 3611 return -1; 3612 } 3613 3614 /** 3615 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3616 * {@code 'token'} but <I>start the search with the last character of the String, and work 3617 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3618 * {@code 'srcStr'} where the match occured. 3619 * 3620 * <BR /><BR /><DIV CLASS=JDHint> 3621 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3622 * </DIV> 3623 * 3624 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3625 * 3626 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3627 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3628 * 3629 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3630 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3631 * 3632 * @param n This is the number of matches to skip when searching for {@code String}-param 3633 * {@code 'token'} before returning an answer. 3634 * 3635 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3636 * {@code String 'srcStr'}. 3637 * 3638 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 3639 * 3640 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3641 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3642 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3643 * 3644 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3645 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3646 * 3647 * @throws StringIndexOutOfBoundsException 3648 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3649 * 3650 * @throws NException If the value of {@code 'n'} is negative, or greater than 3651 * {@code srcStr.length()}, this exception shall throw. 3652 */ 3653 public static int nthFromEnd 3654 (String srcStr, int sPos, int ePos, int n, String token, Predicate<Character> extraDelimiterTest) 3655 { 3656 NException.check(n, srcStr); 3657 3658 LV l = new LV(srcStr, sPos, ePos, token.length()); 3659 int tokenLen = token.length(); 3660 3661 for (int i=(l.end-1); i >= l.start; i--) 3662 3663 if ( srcStr.regionMatches(i, token, 0, tokenLen) 3664 && ( (i==0) 3665 || Character.isWhitespace(srcStr.charAt(i-1)) 3666 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3667 && ( ((i + tokenLen) == srcStr.length()) 3668 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 3669 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 3670 ) 3671 if (--n == 0) return i; 3672 3673 return -1; 3674 } 3675 3676 /** 3677 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3678 * {@code 'token'} but <I>start the search with the last character of the String, and work 3679 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3680 * {@code 'srcStr'} where the match occured. 3681 * 3682 * <BR /><BR /><DIV CLASS=JDHint> 3683 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3684 * </DIV> 3685 * 3686 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_SUBSECT> 3687 * 3688 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3689 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3690 * 3691 * @param sPos <EMBED CLASS='external-html' DATA-FILE-ID=SPOSSTR> 3692 * @param ePos <EMBED CLASS='external-html' DATA-FILE-ID=EPOSSTR> 3693 * 3694 * @param n This is the number of matches to skip when searching for {@code String}-param 3695 * {@code 'token'} before returning an answer. 3696 * 3697 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3698 * {@code String 'srcStr'}. 3699 * 3700 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3701 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3702 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3703 * 3704 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3705 * 3706 * @throws StringIndexOutOfBoundsException 3707 * <EMBED CLASS='external-html' DATA-FILE-ID=SIOOB_EX> 3708 * 3709 * @throws NException If the value of {@code 'n'} is negative, or greater than 3710 * {@code srcStr.length()}, this exception shall throw. 3711 */ 3712 public static int nthFromEnd(String srcStr, int sPos, int ePos, int n, String token) 3713 { 3714 NException.check(n, srcStr); 3715 3716 LV l = new LV(srcStr, sPos, ePos, token.length()); 3717 int tokenLen = token.length(); 3718 3719 for (int i=(l.end-1); i >= l.start; i--) 3720 3721 if ( srcStr.regionMatches(i, token, 0, tokenLen) 3722 && ( (i==0) 3723 || Character.isWhitespace(srcStr.charAt(i-1))) 3724 && ( ((i + tokenLen) == srcStr.length()) 3725 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 3726 ) 3727 if (--n == 0) return i; 3728 3729 return -1; 3730 } 3731 3732 /** 3733 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3734 * {@code 'c'} but <I>start the search with the last character of the String, and work 3735 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3736 * {@code 'srcStr'} where the match occured. 3737 * 3738 * <BR /><BR /><DIV CLASS=JDHint> 3739 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3740 * </DIV> 3741 * 3742 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3743 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3744 * 3745 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3746 * {@code 'c'} before returning an answer. 3747 * 3748 * @param c This is the character that will be 'searched-for' in input-parameter 3749 * {@code String 'srcStr'}. 3750 * 3751 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 3752 * 3753 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3754 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3755 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3756 * 3757 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3758 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3759 * 3760 * @throws NException If the value of {@code 'n'} is negative, or greater than 3761 * {@code srcStr.length()}, this exception shall throw. 3762 */ 3763 public static int nthFromEnd 3764 (String srcStr, int n, char c, Predicate<Character> extraDelimiterTest) 3765 { 3766 NException.check(n, srcStr); 3767 3768 LV l = new LV(srcStr, 0, -1); 3769 3770 for (int i=(l.end-1); i >= l.start; i--) 3771 3772 if ( (c == srcStr.charAt(i)) 3773 && ( (i==0) 3774 || Character.isWhitespace(srcStr.charAt(i-1)) 3775 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3776 && ( ((i+1) == srcStr.length()) 3777 || Character.isWhitespace(srcStr.charAt(i+1)) 3778 || extraDelimiterTest.test(srcStr.charAt(i+1))) 3779 ) 3780 if (--n == 0) return i; 3781 3782 return -1; 3783 } 3784 3785 /** 3786 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 3787 * {@code 'c'} but <I>start the search with the last character of the String, and work 3788 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3789 * {@code 'srcStr'} where the match occured. 3790 * 3791 * <BR /><BR /><DIV CLASS=JDHint> 3792 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3793 * </DIV> 3794 * 3795 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3796 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3797 * 3798 * @param n This is the number of matches to skip when searching for {@code char}-parameter 3799 * {@code 'c'} before returning an answer. 3800 * 3801 * @param c This is the character that will be 'searched-for' in input-parameter 3802 * {@code String 'srcStr'}. 3803 * 3804 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3805 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>counting 3806 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3807 * 3808 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3809 * 3810 * @throws NException If the value of {@code 'n'} is negative, or greater than 3811 * {@code srcStr.length()}, this exception shall throw. 3812 */ 3813 public static int nthFromEnd(String srcStr, int n, char c) 3814 { 3815 NException.check(n, srcStr); 3816 3817 LV l = new LV(srcStr, 0, -1); 3818 3819 for (int i=(l.end-1); i >= l.start; i--) 3820 3821 if ( (c == srcStr.charAt(i)) 3822 && ( (i==0) 3823 || Character.isWhitespace(srcStr.charAt(i-1))) 3824 && ( ((i+1) == srcStr.length()) 3825 || Character.isWhitespace(srcStr.charAt(i+1))) 3826 ) 3827 if (--n == 0) return i; 3828 3829 return -1; 3830 } 3831 3832 /** 3833 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3834 * {@code 'token'} but <I>start the search with the last character of the String, and work 3835 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3836 * {@code 'srcStr'} where the match occured. 3837 * 3838 * <BR /><BR /><DIV CLASS=JDHint> 3839 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3840 * </DIV> 3841 * 3842 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3843 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3844 * 3845 * @param n This is the number of matches to skip when searching for {@code String}-param 3846 * {@code 'token'} before returning an answer. 3847 * 3848 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3849 * {@code String 'srcStr'}. 3850 * 3851 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 3852 * 3853 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3854 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3855 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3856 * 3857 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3858 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3859 * 3860 * @throws NException If the value of {@code 'n'} is negative, or greater than 3861 * {@code srcStr.length()}, this exception shall throw. 3862 */ 3863 public static int nthFromEnd 3864 (String srcStr, int n, String token, Predicate<Character> extraDelimiterTest) 3865 { 3866 NException.check(n, srcStr); 3867 3868 LV l = new LV(srcStr, 0, -1, token.length()); 3869 int tokenLen = token.length(); 3870 3871 for (int i=(l.end-1); i >= l.start; i--) 3872 3873 if ( srcStr.regionMatches(i, token, 0, tokenLen) 3874 && ( (i==0) 3875 || Character.isWhitespace(srcStr.charAt(i-1)) 3876 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3877 && ( ((i + tokenLen) == srcStr.length()) 3878 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 3879 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 3880 ) 3881 if (--n == 0) return i; 3882 3883 return -1; 3884 } 3885 3886 /** 3887 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 3888 * {@code 'token'} but <I>start the search with the last character of the String, and work 3889 * <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 3890 * {@code 'srcStr'} where the match occured. 3891 * 3892 * <BR /><BR /><DIV CLASS=JDHint> 3893 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 3894 * </DIV> 3895 * 3896 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3897 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3898 * 3899 * @param n This is the number of matches to skip when searching for {@code String}-param 3900 * {@code 'token'} before returning an answer. 3901 * 3902 * @param token This is the sub-string that will be 'searched-for' in input-parameter 3903 * {@code String 'srcStr'}. 3904 * 3905 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3906 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>counting 3907 * <B STYLE='color: red;'>left</B> from the end of {@code 'srcStr'}</I> 3908 * 3909 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 3910 * 3911 * @throws NException If the value of {@code 'n'} is negative, or greater than 3912 * {@code srcStr.length()}, this exception shall throw. 3913 */ 3914 public static int nthFromEnd(String srcStr, int n, String token) 3915 { 3916 NException.check(n, srcStr); 3917 3918 LV l = new LV(srcStr, 0, -1, token.length()); 3919 int tokenLen = token.length(); 3920 3921 for (int i=(l.end-1); i >= l.start; i--) 3922 3923 if ( srcStr.regionMatches(i, token, 0, tokenLen) 3924 && ( (i==0) 3925 || Character.isWhitespace(srcStr.charAt(i-1))) 3926 && ( ((i + tokenLen) == srcStr.length()) 3927 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 3928 ) 3929 if (--n == 0) return i; 3930 3931 return -1; 3932 } 3933 3934 /** 3935 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 3936 * {@code 'c'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 3937 * position {@code 'fromIndex'}</I>. Return the integer index-location into 3938 * {@code 'srcStr'} where the match occured. 3939 * 3940 * <BR /><BR /><DIV CLASS=JDHint> 3941 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3942 * </DIV> 3943 * 3944 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3945 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3946 * 3947 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 3948 * from where the search shall start. 3949 * 3950 * @param c This is the character that will be 'searched-for' in input-parameter 3951 * {@code String 'srcStr'}. 3952 * 3953 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 3954 * 3955 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 3956 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 3957 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 3958 * {@code 'fromIndex'}</I> 3959 * 3960 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 3961 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 3962 */ 3963 public static int left_CI 3964 (String srcStr, int fromIndex, char c, Predicate<Character> extraDelimiterTest) 3965 { 3966 LV l = new LV(srcStr, 0, fromIndex); 3967 3968 c = Character.toLowerCase(c); 3969 3970 for (int i=l.end; i >= 0; i--) 3971 3972 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 3973 && ( (i==0) 3974 || Character.isWhitespace(srcStr.charAt(i-1)) 3975 || extraDelimiterTest.test(srcStr.charAt(i-1))) 3976 && ( ((i+1) == srcStr.length()) 3977 || Character.isWhitespace(srcStr.charAt(i+1)) 3978 || extraDelimiterTest.test(srcStr.charAt(i+1))) 3979 ) 3980 return i; 3981 3982 return -1; 3983 } 3984 3985 /** 3986 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 3987 * {@code 'c'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 3988 * position {@code 'fromIndex'}</I>. Return the integer index-location into 3989 * {@code 'srcStr'} where the match occured. 3990 * 3991 * <BR /><BR /><DIV CLASS=JDHint> 3992 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 3993 * </DIV> 3994 * 3995 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 3996 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 3997 * 3998 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 3999 * from where the search shall start. 4000 * 4001 * @param c This is the character that will be 'searched-for' in input-parameter 4002 * {@code String 'srcStr'}. 4003 * 4004 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4005 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4006 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4007 * {@code 'fromIndex'}</I> 4008 * 4009 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4010 */ 4011 public static int left_CI(String srcStr, int fromIndex, char c) 4012 { 4013 LV l = new LV(srcStr, 0, fromIndex); 4014 4015 c = Character.toLowerCase(c); 4016 4017 for (int i=l.end; i >= 0; i--) 4018 4019 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 4020 && ( (i==0) 4021 || Character.isWhitespace(srcStr.charAt(i-1))) 4022 && ( ((i+1) == srcStr.length()) 4023 || Character.isWhitespace(srcStr.charAt(i+1))) 4024 ) 4025 return i; 4026 4027 return -1; 4028 } 4029 4030 /** 4031 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 4032 * {@code 'token'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 4033 * position {@code 'fromIndex'}</I>. Return the integer index-location into 4034 * {@code 'srcStr'} where the match occured. 4035 * 4036 * <BR /><BR /><DIV CLASS=JDHint> 4037 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 4038 * </DIV> 4039 * 4040 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4041 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4042 * 4043 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4044 * from where the search shall start. 4045 * 4046 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4047 * {@code String 'srcStr'}. 4048 * 4049 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 4050 * 4051 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4052 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4053 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4054 * {@code 'fromIndex'}</I> 4055 * 4056 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4057 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4058 */ 4059 public static int left_CI 4060 (String srcStr, int fromIndex, String token, Predicate<Character> extraDelimiterTest) 4061 { 4062 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4063 int tokenLen = token.length(); 4064 4065 for (int i=l.end; i >= 0; i--) 4066 4067 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 4068 && ( (i==0) 4069 || Character.isWhitespace(srcStr.charAt(i-1)) 4070 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4071 && ( ((i + tokenLen) == srcStr.length()) 4072 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 4073 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 4074 ) 4075 return i; 4076 4077 return -1; 4078 } 4079 4080 /** 4081 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 4082 * {@code 'token'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 4083 * position {@code 'fromIndex'}</I>. Return the integer index-location into 4084 * {@code 'srcStr'} where the match occured. 4085 * 4086 * <BR /><BR /><DIV CLASS=JDHint> 4087 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 4088 * </DIV> 4089 * 4090 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4091 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4092 * 4093 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4094 * from where the search shall start. 4095 * 4096 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4097 * {@code String 'srcStr'}. 4098 * 4099 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4100 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4101 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4102 * {@code 'fromIndex'}</I> 4103 * 4104 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4105 */ 4106 public static int left_CI(String srcStr, int fromIndex, String token) 4107 { 4108 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4109 int tokenLen = token.length(); 4110 4111 for (int i=l.end; i >= 0; i--) 4112 4113 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 4114 && ( (i==0) 4115 || Character.isWhitespace(srcStr.charAt(i-1))) 4116 && ( ((i + tokenLen) == srcStr.length()) 4117 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 4118 ) 4119 return i; 4120 4121 return -1; 4122 } 4123 4124 /** 4125 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 4126 * {@code 'c'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 4127 * position {@code 'fromIndex'}</I>. Return the integer index-location into 4128 * {@code 'srcStr'} where the match occured. 4129 * 4130 * <BR /><BR /><DIV CLASS=JDHint> 4131 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4132 * </DIV> 4133 * 4134 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4135 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4136 * 4137 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4138 * from where the search shall start. 4139 * 4140 * @param c This is the character that will be 'searched-for' in input-parameter 4141 * {@code String 'srcStr'}. 4142 * 4143 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 4144 * 4145 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4146 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4147 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4148 * {@code 'fromIndex'}</I> 4149 * 4150 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4151 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4152 */ 4153 public static int left 4154 (String srcStr, int fromIndex, char c, Predicate<Character> extraDelimiterTest) 4155 { 4156 LV l = new LV(srcStr, 0, fromIndex); 4157 4158 for (int i=l.end; i >= 0; i--) 4159 4160 if ( (c == srcStr.charAt(i)) 4161 && ( (i==0) 4162 || Character.isWhitespace(srcStr.charAt(i-1)) 4163 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4164 && ( ((i+1) == srcStr.length()) 4165 || Character.isWhitespace(srcStr.charAt(i+1)) 4166 || extraDelimiterTest.test(srcStr.charAt(i+1))) 4167 ) 4168 return i; 4169 4170 return -1; 4171 } 4172 4173 /** 4174 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code char}-parameter 4175 * {@code 'c'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 4176 * position {@code 'fromIndex'}</I>. Return the integer index-location into 4177 * {@code 'srcStr'} where the match occured. 4178 * 4179 * <BR /><BR /><DIV CLASS=JDHint> 4180 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4181 * </DIV> 4182 * 4183 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4184 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4185 * 4186 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4187 * from where the search shall start. 4188 * 4189 * @param c This is the character that will be 'searched-for' in input-parameter 4190 * {@code String 'srcStr'}. 4191 * 4192 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4193 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4194 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4195 * {@code 'fromIndex'}</I> 4196 * 4197 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4198 */ 4199 public static int left(String srcStr, int fromIndex, char c) 4200 { 4201 LV l = new LV(srcStr, 0, fromIndex); 4202 4203 for (int i=l.end; i >= 0; i--) 4204 4205 if ( (c == srcStr.charAt(i)) 4206 && ( (i==0) 4207 || Character.isWhitespace(srcStr.charAt(i-1))) 4208 && ( ((i+1) == srcStr.length()) 4209 || Character.isWhitespace(srcStr.charAt(i+1))) 4210 ) 4211 return i; 4212 4213 return -1; 4214 } 4215 4216 /** 4217 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 4218 * {@code 'token'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 4219 * position {@code 'fromIndex'}</I>. Return the integer index-location into 4220 * {@code 'srcStr'} where the match occured. 4221 * 4222 * <BR /><BR /><DIV CLASS=JDHint> 4223 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4224 * </DIV> 4225 * 4226 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4227 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4228 * 4229 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4230 * from where the search shall start. 4231 * 4232 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4233 * {@code String 'srcStr'}. 4234 * 4235 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 4236 * 4237 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4238 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4239 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4240 * {@code 'fromIndex'}</I> 4241 * 4242 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4243 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4244 */ 4245 public static int left 4246 (String srcStr, int fromIndex, String token, Predicate<Character> extraDelimiterTest) 4247 { 4248 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4249 int tokenLen = token.length(); 4250 4251 for (int i=l.end; i >= 0; i--) 4252 4253 if ( srcStr.regionMatches(i, token, 0, tokenLen) 4254 && ( (i==0) 4255 || Character.isWhitespace(srcStr.charAt(i-1)) 4256 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4257 && ( ((i + tokenLen) == srcStr.length()) 4258 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 4259 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 4260 ) 4261 return i; 4262 4263 return -1; 4264 } 4265 4266 /** 4267 * Search for the <B STYLE='color: red'>first</B> {@code token}-match of {@code String}-param 4268 * {@code 'token'} <I>searching <B STYLE='color: red;'>left</B> beginning at {@code 'srcStr'} 4269 * position {@code 'fromIndex'}</I>. Return the integer index-location into 4270 * {@code 'srcStr'} where the match occured. 4271 * 4272 * <BR /><BR /><DIV CLASS=JDHint> 4273 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4274 * </DIV> 4275 * 4276 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4277 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4278 * 4279 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4280 * from where the search shall start. 4281 * 4282 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4283 * {@code String 'srcStr'}. 4284 * 4285 * @return The {@code 'srcStr' String}-index of the <B STYLE='color: red;'>nth</B> identified 4286 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4287 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4288 * {@code 'fromIndex'}</I> 4289 * 4290 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4291 */ 4292 public static int left(String srcStr, int fromIndex, String token) 4293 { 4294 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4295 int tokenLen = token.length(); 4296 4297 for (int i=l.end; i >= 0; i--) 4298 4299 if ( srcStr.regionMatches(i, token, 0, tokenLen) 4300 && ( (i==0) 4301 || Character.isWhitespace(srcStr.charAt(i-1))) 4302 && ( ((i + tokenLen) == srcStr.length()) 4303 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 4304 ) 4305 return i; 4306 4307 return -1; 4308 } 4309 4310 /** 4311 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 4312 * {@code 'c'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4313 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4314 * {@code 'srcStr'} where the match occured. 4315 * 4316 * <BR /><BR /><DIV CLASS=JDHint> 4317 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 4318 * </DIV> 4319 * 4320 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4321 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4322 * 4323 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4324 * from where the search shall start. 4325 * 4326 * @param n This is the number of matches to skip when searching for {@code char}-parameter 4327 * {@code 'c'} before returning an answer. 4328 * 4329 * @param c This is the character that will be 'searched-for' in input-parameter 4330 * {@code String 'srcStr'}. 4331 * 4332 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 4333 * 4334 * @return The {@code 'srcStr' String}-index of the nth identified 4335 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4336 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4337 * {@code 'fromIndex'}</I> 4338 * 4339 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4340 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4341 * 4342 * @throws NException If the value of {@code 'n'} is negative, or greater than 4343 * {@code srcStr.length()}, this exception shall throw. 4344 */ 4345 public static int nthLeft_CI 4346 (String srcStr, int fromIndex, int n, char c, Predicate<Character> extraDelimiterTest) 4347 { 4348 NException.check(n, srcStr); 4349 4350 LV l = new LV(srcStr, 0, fromIndex); 4351 4352 c = Character.toLowerCase(c); 4353 4354 for (int i=l.end; i >= 0; i--) 4355 4356 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 4357 && ( (i==0) 4358 || Character.isWhitespace(srcStr.charAt(i-1)) 4359 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4360 && ( ((i+1) == srcStr.length()) 4361 || Character.isWhitespace(srcStr.charAt(i+1)) 4362 || extraDelimiterTest.test(srcStr.charAt(i+1))) 4363 ) 4364 if (--n == 0) return i; 4365 4366 return -1; 4367 } 4368 4369 /** 4370 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 4371 * {@code 'c'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4372 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4373 * {@code 'srcStr'} where the match occured. 4374 * 4375 * <BR /><BR /><DIV CLASS=JDHint> 4376 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 4377 * </DIV> 4378 * 4379 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4380 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4381 * 4382 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4383 * from where the search shall start. 4384 * 4385 * @param n This is the number of matches to skip when searching for {@code char}-parameter 4386 * {@code 'c'} before returning an answer. 4387 * 4388 * @param c This is the character that will be 'searched-for' in input-parameter 4389 * {@code String 'srcStr'}. 4390 * 4391 * @return The {@code 'srcStr' String}-index of the nth identified 4392 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4393 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4394 * {@code 'fromIndex'}</I> 4395 * 4396 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4397 * 4398 * @throws NException If the value of {@code 'n'} is negative, or greater than 4399 * {@code srcStr.length()}, this exception shall throw. 4400 */ 4401 public static int nthLeft_CI(String srcStr, int fromIndex, int n, char c) 4402 { 4403 NException.check(n, srcStr); 4404 4405 LV l = new LV(srcStr, 0, fromIndex); 4406 4407 c = Character.toLowerCase(c); 4408 4409 for (int i=l.end; i >= 0; i--) 4410 4411 if ( (c == Character.toLowerCase(srcStr.charAt(i))) 4412 && ( (i==0) 4413 || Character.isWhitespace(srcStr.charAt(i-1))) 4414 && ( ((i+1) == srcStr.length()) 4415 || Character.isWhitespace(srcStr.charAt(i+1))) 4416 ) 4417 if (--n == 0) return i; 4418 4419 return -1; 4420 } 4421 4422 /** 4423 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 4424 * {@code 'token'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4425 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4426 * {@code 'srcStr'} where the match occured. 4427 * 4428 * <BR /><BR /><DIV CLASS=JDHint> 4429 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 4430 * </DIV> 4431 * 4432 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4433 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4434 * 4435 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4436 * from where the search shall start. 4437 * 4438 * @param n This is the number of matches to skip when searching for {@code String}-param 4439 * {@code 'token'} before returning an answer. 4440 * 4441 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4442 * {@code String 'srcStr'}. 4443 * 4444 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 4445 * 4446 * @return The {@code 'srcStr' String}-index of the nth identified 4447 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4448 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4449 * {@code 'fromIndex'}</I> 4450 * 4451 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4452 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4453 * 4454 * @throws NException If the value of {@code 'n'} is negative, or greater than 4455 * {@code srcStr.length()}, this exception shall throw. 4456 */ 4457 public static int nthLeft_CI 4458 (String srcStr, int fromIndex, int n, String token, Predicate<Character> extraDelimiterTest) 4459 { 4460 NException.check(n, srcStr); 4461 4462 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4463 int tokenLen = token.length(); 4464 4465 for (int i=l.end; i >= 0; i--) 4466 4467 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 4468 && ( (i==0) 4469 || Character.isWhitespace(srcStr.charAt(i-1)) 4470 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4471 && ( ((i + tokenLen) == srcStr.length()) 4472 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 4473 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 4474 ) 4475 if (--n == 0) return i; 4476 4477 return -1; 4478 } 4479 4480 /** 4481 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 4482 * {@code 'token'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4483 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4484 * {@code 'srcStr'} where the match occured. 4485 * 4486 * <BR /><BR /><DIV CLASS=JDHint> 4487 * The comparisons performed <B STYLE='color: red'>** are not **</B> case-sensitive 4488 * </DIV> 4489 * 4490 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4491 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4492 * 4493 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4494 * from where the search shall start. 4495 * 4496 * @param n This is the number of matches to skip when searching for {@code String}-param 4497 * {@code 'token'} before returning an answer. 4498 * 4499 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4500 * {@code String 'srcStr'}. 4501 * 4502 * @return The {@code 'srcStr' String}-index of the nth identified 4503 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4504 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4505 * {@code 'fromIndex'}</I> 4506 * 4507 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4508 * 4509 * @throws NException If the value of {@code 'n'} is negative, or greater than 4510 * {@code srcStr.length()}, this exception shall throw. 4511 */ 4512 public static int nthLeft_CI(String srcStr, int fromIndex, int n, String token) 4513 { 4514 NException.check(n, srcStr); 4515 4516 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4517 int tokenLen = token.length(); 4518 4519 for (int i=l.end; i >= 0; i--) 4520 4521 if ( srcStr.regionMatches(true, i, token, 0, tokenLen) 4522 && ( (i==0) 4523 || Character.isWhitespace(srcStr.charAt(i-1))) 4524 && ( ((i + tokenLen) == srcStr.length()) 4525 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 4526 ) 4527 if (--n == 0) return i; 4528 4529 return -1; 4530 } 4531 4532 /** 4533 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 4534 * {@code 'c'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4535 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4536 * {@code 'srcStr'} where the match occured. 4537 * 4538 * <BR /><BR /><DIV CLASS=JDHint> 4539 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4540 * </DIV> 4541 * 4542 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4543 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4544 * 4545 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4546 * from where the search shall start. 4547 * 4548 * @param n This is the number of matches to skip when searching for {@code char}-parameter 4549 * {@code 'c'} before returning an answer. 4550 * 4551 * @param c This is the character that will be 'searched-for' in input-parameter 4552 * {@code String 'srcStr'}. 4553 * 4554 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_CHAR> 4555 * 4556 * @return The {@code 'srcStr' String}-index of the nth identified 4557 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4558 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4559 * {@code 'fromIndex'}</I> 4560 * 4561 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4562 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4563 * 4564 * @throws NException If the value of {@code 'n'} is negative, or greater than 4565 * {@code srcStr.length()}, this exception shall throw. 4566 */ 4567 public static int nthLeft 4568 (String srcStr, int fromIndex, int n, char c, Predicate<Character> extraDelimiterTest) 4569 { 4570 NException.check(n, srcStr); 4571 4572 LV l = new LV(srcStr, 0, fromIndex); 4573 4574 for (int i=l.end; i >= 0; i--) 4575 4576 if ( (c == srcStr.charAt(i)) 4577 && ( (i==0) 4578 || Character.isWhitespace(srcStr.charAt(i-1)) 4579 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4580 && ( ((i+1) == srcStr.length()) 4581 || Character.isWhitespace(srcStr.charAt(i+1)) 4582 || extraDelimiterTest.test(srcStr.charAt(i+1))) 4583 ) 4584 if (--n == 0) return i; 4585 4586 return -1; 4587 } 4588 4589 /** 4590 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code char}-parameter 4591 * {@code 'c'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4592 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4593 * {@code 'srcStr'} where the match occured. 4594 * 4595 * <BR /><BR /><DIV CLASS=JDHint> 4596 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4597 * </DIV> 4598 * 4599 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4600 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4601 * 4602 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4603 * from where the search shall start. 4604 * 4605 * @param n This is the number of matches to skip when searching for {@code char}-parameter 4606 * {@code 'c'} before returning an answer. 4607 * 4608 * @param c This is the character that will be 'searched-for' in input-parameter 4609 * {@code String 'srcStr'}. 4610 * 4611 * @return The {@code 'srcStr' String}-index of the nth identified 4612 * <B>{@code TOKEN-Character}</B> match in {@code 'srcStr'}, <I>performing the search in the 4613 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4614 * {@code 'fromIndex'}</I> 4615 * 4616 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_CHAR_RET> 4617 * 4618 * @throws NException If the value of {@code 'n'} is negative, or greater than 4619 * {@code srcStr.length()}, this exception shall throw. 4620 */ 4621 public static int nthLeft(String srcStr, int fromIndex, int n, char c) 4622 { 4623 NException.check(n, srcStr); 4624 4625 LV l = new LV(srcStr, 0, fromIndex); 4626 4627 for (int i=l.end; i >= 0; i--) 4628 4629 if ( (c == srcStr.charAt(i)) 4630 && ( (i==0) 4631 || Character.isWhitespace(srcStr.charAt(i-1))) 4632 && ( ((i+1) == srcStr.length()) 4633 || Character.isWhitespace(srcStr.charAt(i+1))) 4634 ) 4635 if (--n == 0) return i; 4636 4637 return -1; 4638 } 4639 4640 /** 4641 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 4642 * {@code 'token'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4643 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4644 * {@code 'srcStr'} where the match occured. 4645 * 4646 * <BR /><BR /><DIV CLASS=JDHint> 4647 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4648 * </DIV> 4649 * 4650 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4651 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4652 * 4653 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4654 * from where the search shall start. 4655 * 4656 * @param n This is the number of matches to skip when searching for {@code String}-param 4657 * {@code 'token'} before returning an answer. 4658 * 4659 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4660 * {@code String 'srcStr'}. 4661 * 4662 * @param extraDelimiterTest <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_STR> 4663 * 4664 * @return The {@code 'srcStr' String}-index of the nth identified 4665 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4666 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4667 * {@code 'fromIndex'}</I> 4668 * 4669 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4670 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_XTRADELIM_RET> 4671 * 4672 * @throws NException If the value of {@code 'n'} is negative, or greater than 4673 * {@code srcStr.length()}, this exception shall throw. 4674 */ 4675 public static int nthLeft 4676 (String srcStr, int fromIndex, int n, String token, Predicate<Character> extraDelimiterTest) 4677 { 4678 NException.check(n, srcStr); 4679 4680 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4681 int tokenLen = token.length(); 4682 4683 for (int i=l.end; i >= 0; i--) 4684 4685 if ( srcStr.regionMatches(i, token, 0, tokenLen) 4686 && ( (i==0) 4687 || Character.isWhitespace(srcStr.charAt(i-1)) 4688 || extraDelimiterTest.test(srcStr.charAt(i-1))) 4689 && ( ((i + tokenLen) == srcStr.length()) 4690 || Character.isWhitespace(srcStr.charAt(i + tokenLen)) 4691 || extraDelimiterTest.test(srcStr.charAt(i + tokenLen))) 4692 ) 4693 if (--n == 0) return i; 4694 4695 return -1; 4696 } 4697 4698 /** 4699 * Search for the <B STYLE='color: red'>nth</B> {@code token}-match of {@code String}-param 4700 * {@code 'token'} in {@code 'srcStr'}, but <I>begin the search at index-position {@code 'fromIndex'} 4701 * and work <B STYLE='color: red;'>left</B></I>. Return the integer index-location into 4702 * {@code 'srcStr'} where the match occured. 4703 * 4704 * <BR /><BR /><DIV CLASS=JDHint> 4705 * The comparisons performed <B STYLE='color: red'>** are **</B> case-sensitive 4706 * </DIV> 4707 * 4708 * @param srcStr This may be any {@code java.lang.String}. Its contents will be searched for 4709 * the specified {@code token}-matches, and an an index-pointer (an integer) will be returned. 4710 * 4711 * @param fromIndex This is the right-most index-position in {@code 'srcStr'} (*INCLUSIVE*) 4712 * from where the search shall start. 4713 * 4714 * @param n This is the number of matches to skip when searching for {@code String}-param 4715 * {@code 'token'} before returning an answer. 4716 * 4717 * @param token This is the sub-string that will be 'searched-for' in input-parameter 4718 * {@code String 'srcStr'}. 4719 * 4720 * @return The {@code 'srcStr' String}-index of the nth identified 4721 * <B>{@code TOKEN-String}</B> match in {@code 'srcStr'}, <I>performing the search in the 4722 * <B STYLE='color: red;'>left</B> direction, beginning at {@code String}-index 4723 * {@code 'fromIndex'}</I> 4724 * 4725 * <EMBED CLASS='external-html' DATA-FILE-ID=STIO_STR_RET> 4726 * 4727 * @throws NException If the value of {@code 'n'} is negative, or greater than 4728 * {@code srcStr.length()}, this exception shall throw. 4729 */ 4730 public static int nthLeft(String srcStr, int fromIndex, int n, String token) 4731 { 4732 NException.check(n, srcStr); 4733 4734 LV l = new LV(srcStr, 0, fromIndex, token.length()); 4735 int tokenLen = token.length(); 4736 4737 for (int i=l.end; i >= 0; i--) 4738 4739 if ( srcStr.regionMatches(i, token, 0, tokenLen) 4740 && ( (i==0) 4741 || Character.isWhitespace(srcStr.charAt(i-1))) 4742 && ( ((i + tokenLen) == srcStr.length()) 4743 || Character.isWhitespace(srcStr.charAt(i + tokenLen))) 4744 ) 4745 if (--n == 0) return i; 4746 4747 return -1; 4748 } 4749 4750}