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