OLD | NEW |
1 /* | 1 /* |
2 ********************************************************************** | 2 ********************************************************************** |
3 * Copyright (C) 2004-2013, International Business Machines | 3 * Copyright (C) 2004-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ********************************************************************** | 5 ********************************************************************** |
6 * file name: uregex.h | 6 * file name: uregex.h |
7 * encoding: US-ASCII | 7 * encoding: US-ASCII |
8 * indentation:4 | 8 * indentation:4 |
9 * | 9 * |
10 * created on: 2004mar09 | 10 * created on: 2004mar09 |
11 * created by: Andy Heninger | 11 * created by: Andy Heninger |
12 * | 12 * |
13 * ICU Regular Expressions, API for C | 13 * ICU Regular Expressions, API for C |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 * | 480 * |
481 * <p>If startIndex is >= 0 any input region that was set for this | 481 * <p>If startIndex is >= 0 any input region that was set for this |
482 * URegularExpression is reset before the operation begins. | 482 * URegularExpression is reset before the operation begins. |
483 * | 483 * |
484 * <p>If the specified starting index == -1 the match begins at the start of
the input | 484 * <p>If the specified starting index == -1 the match begins at the start of
the input |
485 * region, or at the start of the full string if no region has been specified
. | 485 * region, or at the start of the full string if no region has been specified
. |
486 * This corresponds directly with Matcher.lookingAt() in Java. | 486 * This corresponds directly with Matcher.lookingAt() in Java. |
487 * | 487 * |
488 * <p>If the match succeeds then more information can be obtained via the | 488 * <p>If the match succeeds then more information can be obtained via the |
489 * <code>uregexp_start()</code>, <code>uregexp_end()</code>, | 489 * <code>uregexp_start()</code>, <code>uregexp_end()</code>, |
490 * and <code>uregexp_group()</code> functions.</p> | 490 * and <code>uregex_group()</code> functions.</p> |
491 * | 491 * |
492 * @param regexp The compiled regular expression. | 492 * @param regexp The compiled regular expression. |
493 * @param startIndex The input string (native) index at which to begin ma
tching, or | 493 * @param startIndex The input string (native) index at which to begin ma
tching, or |
494 * -1 to match the Input Region | 494 * -1 to match the Input Region |
495 * @param status A reference to a UErrorCode to receive any errors. | 495 * @param status A reference to a UErrorCode to receive any errors. |
496 * @return TRUE if there is a match. | 496 * @return TRUE if there is a match. |
497 * @stable ICU 3.0 | 497 * @stable ICU 3.0 |
498 */ | 498 */ |
499 U_STABLE UBool U_EXPORT2 | 499 U_STABLE UBool U_EXPORT2 |
500 uregex_lookingAt(URegularExpression *regexp, | 500 uregex_lookingAt(URegularExpression *regexp, |
501 int32_t startIndex, | 501 int32_t startIndex, |
502 UErrorCode *status); | 502 UErrorCode *status); |
503 | 503 |
504 /** | 504 /** |
505 * 64bit version of uregex_lookingAt. | 505 * 64bit version of uregex_lookingAt. |
506 * Attempts to match the input string, starting from the specified index, aga
inst the pattern. | 506 * Attempts to match the input string, starting from the specified index, aga
inst the pattern. |
507 * The match may be of any length, and is not required to extend to the end | 507 * The match may be of any length, and is not required to extend to the end |
508 * of the input string. Contrast with uregex_matches(). | 508 * of the input string. Contrast with uregex_matches(). |
509 * | 509 * |
510 * <p>If startIndex is >= 0 any input region that was set for this | 510 * <p>If startIndex is >= 0 any input region that was set for this |
511 * URegularExpression is reset before the operation begins. | 511 * URegularExpression is reset before the operation begins. |
512 * | 512 * |
513 * <p>If the specified starting index == -1 the match begins at the start of
the input | 513 * <p>If the specified starting index == -1 the match begins at the start of
the input |
514 * region, or at the start of the full string if no region has been specified
. | 514 * region, or at the start of the full string if no region has been specified
. |
515 * This corresponds directly with Matcher.lookingAt() in Java. | 515 * This corresponds directly with Matcher.lookingAt() in Java. |
516 * | 516 * |
517 * <p>If the match succeeds then more information can be obtained via the | 517 * <p>If the match succeeds then more information can be obtained via the |
518 * <code>uregexp_start()</code>, <code>uregexp_end()</code>, | 518 * <code>uregexp_start()</code>, <code>uregexp_end()</code>, |
519 * and <code>uregexp_group()</code> functions.</p> | 519 * and <code>uregex_group()</code> functions.</p> |
520 * | 520 * |
521 * @param regexp The compiled regular expression. | 521 * @param regexp The compiled regular expression. |
522 * @param startIndex The input string (native) index at which to begin ma
tching, or | 522 * @param startIndex The input string (native) index at which to begin ma
tching, or |
523 * -1 to match the Input Region | 523 * -1 to match the Input Region |
524 * @param status A reference to a UErrorCode to receive any errors. | 524 * @param status A reference to a UErrorCode to receive any errors. |
525 * @return TRUE if there is a match. | 525 * @return TRUE if there is a match. |
526 * @stable ICU 4.6 | 526 * @stable ICU 4.6 |
527 */ | 527 */ |
528 U_STABLE UBool U_EXPORT2 | 528 U_STABLE UBool U_EXPORT2 |
529 uregex_lookingAt64(URegularExpression *regexp, | 529 uregex_lookingAt64(URegularExpression *regexp, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 * Get the number of capturing groups in this regular expression's pattern. | 600 * Get the number of capturing groups in this regular expression's pattern. |
601 * @param regexp The compiled regular expression. | 601 * @param regexp The compiled regular expression. |
602 * @param status A reference to a UErrorCode to receive any errors. | 602 * @param status A reference to a UErrorCode to receive any errors. |
603 * @return the number of capture groups | 603 * @return the number of capture groups |
604 * @stable ICU 3.0 | 604 * @stable ICU 3.0 |
605 */ | 605 */ |
606 U_STABLE int32_t U_EXPORT2 | 606 U_STABLE int32_t U_EXPORT2 |
607 uregex_groupCount(URegularExpression *regexp, | 607 uregex_groupCount(URegularExpression *regexp, |
608 UErrorCode *status); | 608 UErrorCode *status); |
609 | 609 |
| 610 #ifndef U_HIDE_DRAFT_API |
| 611 /** |
| 612 * Get the group number corresponding to a named capture group. |
| 613 * The returned number can be used with any function that access |
| 614 * capture groups by number. |
| 615 * |
| 616 * The function returns an error status if the specified name does not |
| 617 * appear in the pattern. |
| 618 * |
| 619 * @param regexp The compiled regular expression. |
| 620 * @param groupName The capture group name. |
| 621 * @param nameLength The length of the name, or -1 if the name is a |
| 622 * nul-terminated string. |
| 623 * @param status A pointer to a UErrorCode to receive any errors. |
| 624 * |
| 625 * @draft ICU 55 |
| 626 */ |
| 627 U_DRAFT int32_t U_EXPORT2 |
| 628 uregex_groupNumberFromName(URegularExpression *regexp, |
| 629 const UChar *groupName, |
| 630 int32_t nameLength, |
| 631 UErrorCode *status); |
| 632 |
| 633 |
| 634 /** |
| 635 * Get the group number corresponding to a named capture group. |
| 636 * The returned number can be used with any function that access |
| 637 * capture groups by number. |
| 638 * |
| 639 * The function returns an error status if the specified name does not |
| 640 * appear in the pattern. |
| 641 * |
| 642 * @param regexp The compiled regular expression. |
| 643 * @param groupName The capture group name, |
| 644 * platform invariant characters only. |
| 645 * @param nameLength The length of the name, or -1 if the name is |
| 646 * nul-terminated. |
| 647 * @param status A pointer to a UErrorCode to receive any errors. |
| 648 * |
| 649 * @draft ICU 55 |
| 650 */ |
| 651 U_DRAFT int32_t U_EXPORT2 |
| 652 uregex_groupNumberFromCName(URegularExpression *regexp, |
| 653 const char *groupName, |
| 654 int32_t nameLength, |
| 655 UErrorCode *status); |
| 656 #endif /* U_HIDE_DRAFT_API */ |
| 657 |
610 /** Extract the string for the specified matching expression or subexpression. | 658 /** Extract the string for the specified matching expression or subexpression. |
611 * Group #0 is the complete string of matched text. | 659 * Group #0 is the complete string of matched text. |
612 * Group #1 is the text matched by the first set of capturing parentheses. | 660 * Group #1 is the text matched by the first set of capturing parentheses. |
613 * | 661 * |
614 * @param regexp The compiled regular expression. | 662 * @param regexp The compiled regular expression. |
615 * @param groupNum The capture group to extract. Group 0 is the comple
te | 663 * @param groupNum The capture group to extract. Group 0 is the comple
te |
616 * match. The value of this parameter must be | 664 * match. The value of this parameter must be |
617 * less than or equal to the number of capture groups i
n | 665 * less than or equal to the number of capture groups i
n |
618 * the pattern. | 666 * the pattern. |
619 * @param dest Buffer to receive the matching string data | 667 * @param dest Buffer to receive the matching string data |
620 * @param destCapacity Capacity of the dest buffer. | 668 * @param destCapacity Capacity of the dest buffer. |
621 * @param status A reference to a UErrorCode to receive any errors. | 669 * @param status A reference to a UErrorCode to receive any errors. |
622 * @return Length of matching data, | 670 * @return Length of matching data, |
623 * or -1 if no applicable match. | 671 * or -1 if no applicable match. |
624 * @stable ICU 3.0 | 672 * @stable ICU 3.0 |
625 */ | 673 */ |
626 U_STABLE int32_t U_EXPORT2 | 674 U_STABLE int32_t U_EXPORT2 |
627 uregex_group(URegularExpression *regexp, | 675 uregex_group(URegularExpression *regexp, |
628 int32_t groupNum, | 676 int32_t groupNum, |
629 UChar *dest, | 677 UChar *dest, |
630 int32_t destCapacity, | 678 int32_t destCapacity, |
631 UErrorCode *status); | 679 UErrorCode *status); |
632 | 680 |
633 /** Returns a shallow immutable clone of the entire input string. The returned
UText current native index | 681 /** Returns a shallow immutable clone of the entire input string with the curren
t index set |
634 * is set to the beginning of the requested capture group. The capture group
length is also | 682 * to the beginning of the requested capture group. The capture group length
is also |
635 * returned via groupLength. | 683 * returned via groupLength. |
636 * Group #0 is the complete string of matched text. | 684 * Group #0 is the complete string of matched text. |
637 * Group #1 is the text matched by the first set of capturing parentheses. | 685 * Group #1 is the text matched by the first set of capturing parentheses. |
638 * | 686 * |
639 * @param regexp The compiled regular expression. | 687 * @param regexp The compiled regular expression. |
640 * @param groupNum The capture group to extract. Group 0 is the comple
te | 688 * @param groupNum The capture group to extract. Group 0 is the comple
te |
641 * match. The value of this parameter must be | 689 * match. The value of this parameter must be |
642 * less than or equal to the number of capture groups i
n | 690 * less than or equal to the number of capture groups i
n |
643 * the pattern. | 691 * the pattern. |
644 * @param dest A mutable UText in which to store the current input. | 692 * @param dest A mutable UText in which to store the current input. |
645 * If NULL, a new UText will be created as an immutable
shallow clone | 693 * If NULL, a new UText will be created as an immutable
shallow clone |
646 * of the entire input string. | 694 * of the entire input string. |
647 * @param groupLength The group length of the desired capture group. | 695 * @param groupLength The group length of the desired capture group. Outpu
t parameter. |
648 * @param status A reference to a UErrorCode to receive any errors. | 696 * @param status A reference to a UErrorCode to receive any errors. |
649 * @return The subject text currently associated with this regu
lar expression. | 697 * @return The subject text currently associated with this regu
lar expression. |
650 * If a pre-allocated UText was provided, it will alway
s be used and returned. | 698 * If a pre-allocated UText was provided, it will alway
s be used and returned. |
651 | 699 |
652 * | 700 * |
653 * @stable ICU 4.6 | 701 * @stable ICU 4.6 |
654 */ | 702 */ |
655 U_STABLE UText * U_EXPORT2 | 703 U_STABLE UText * U_EXPORT2 |
656 uregex_groupUText(URegularExpression *regexp, | 704 uregex_groupUText(URegularExpression *regexp, |
657 int32_t groupNum, | 705 int32_t groupNum, |
658 UText *dest, | 706 UText *dest, |
659 int64_t *groupLength, | 707 int64_t *groupLength, |
660 UErrorCode *status); | 708 UErrorCode *status); |
661 | 709 |
662 #ifndef U_HIDE_INTERNAL_API | |
663 /** Extract the string for the specified matching expression or subexpression. | |
664 * Group #0 is the complete string of matched text. | |
665 * Group #1 is the text matched by the first set of capturing parentheses. | |
666 * | |
667 * @param regexp The compiled regular expression. | |
668 * @param groupNum The capture group to extract. Group 0 is the comple
te | |
669 * match. The value of this parameter must be | |
670 * less than or equal to the number of capture groups i
n | |
671 * the pattern. | |
672 * @param dest Mutable UText to receive the matching string data. | |
673 * If NULL, a new UText will be created (which may not
be mutable). | |
674 * @param status A reference to a UErrorCode to receive any errors. | |
675 * @return The matching string data. If a pre-allocated UText w
as provided, | |
676 * it will always be used and returned. | |
677 * | |
678 * @internal ICU 4.4 technology preview | |
679 */ | |
680 U_INTERNAL UText * U_EXPORT2 | |
681 uregex_groupUTextDeep(URegularExpression *regexp, | |
682 int32_t groupNum, | |
683 UText *dest, | |
684 UErrorCode *status); | |
685 #endif /* U_HIDE_INTERNAL_API */ | |
686 | |
687 /** | 710 /** |
688 * Returns the index in the input string of the start of the text matched by
the | 711 * Returns the index in the input string of the start of the text matched by
the |
689 * specified capture group during the previous match operation. Return -1 if | 712 * specified capture group during the previous match operation. Return -1 if |
690 * the capture group was not part of the last match. | 713 * the capture group was not part of the last match. |
691 * Group #0 refers to the complete range of matched text. | 714 * Group #0 refers to the complete range of matched text. |
692 * Group #1 refers to the text matched by the first set of capturing parenthe
ses. | 715 * Group #1 refers to the text matched by the first set of capturing parenthe
ses. |
693 * | 716 * |
694 * @param regexp The compiled regular expression. | 717 * @param regexp The compiled regular expression. |
695 * @param groupNum The capture group number | 718 * @param groupNum The capture group number |
696 * @param status A reference to a UErrorCode to receive any errors. | 719 * @param status A reference to a UErrorCode to receive any errors. |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 * @stable ICU 4.6 | 1605 * @stable ICU 4.6 |
1583 */ | 1606 */ |
1584 U_STABLE void U_EXPORT2 | 1607 U_STABLE void U_EXPORT2 |
1585 uregex_getFindProgressCallback(const URegularExpression *regexp, | 1608 uregex_getFindProgressCallback(const URegularExpression *regexp, |
1586 URegexFindProgressCallback **callback, | 1609 URegexFindProgressCallback **callback, |
1587 const void **context, | 1610 const void **context, |
1588 UErrorCode *status); | 1611 UErrorCode *status); |
1589 | 1612 |
1590 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ | 1613 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS */ |
1591 #endif /* UREGEX_H */ | 1614 #endif /* UREGEX_H */ |
OLD | NEW |