658 }
659
660 /**
661 * Tests for a match in a string. It returns the index of the match, or -1
662 * if not found.
663 *
664 * @param string String to match.
665 * @return Index of match.
666 */
667 Object search(final String string) {
668 final Matcher matcher = pattern.matcher(string);
669
670 int start = 0;
671 if (global) {
672 start = getLastIndex();
673 }
674
675 start = matcher.find(start) ? matcher.start() : -1;
676
677 if (global) {
678 setLastIndex(matcher.end());
679 }
680
681 return start;
682 }
683
684 /**
685 * Fast lastIndex getter
686 * @return last index property as int
687 */
688 public int getLastIndex() {
689 return JSType.toInt32(lastIndex);
690 }
691
692 /**
693 * Fast lastIndex getter
694 * @return last index property as boxed integer
695 */
696 public Object getLastIndexObject() {
697 return lastIndex;
698 }
|
658 }
659
660 /**
661 * Tests for a match in a string. It returns the index of the match, or -1
662 * if not found.
663 *
664 * @param string String to match.
665 * @return Index of match.
666 */
667 Object search(final String string) {
668 final Matcher matcher = pattern.matcher(string);
669
670 int start = 0;
671 if (global) {
672 start = getLastIndex();
673 }
674
675 start = matcher.find(start) ? matcher.start() : -1;
676
677 if (global) {
678 setLastIndex(start == -1? -1 : matcher.end());
679 }
680
681 return start;
682 }
683
684 /**
685 * Fast lastIndex getter
686 * @return last index property as int
687 */
688 public int getLastIndex() {
689 return JSType.toInt32(lastIndex);
690 }
691
692 /**
693 * Fast lastIndex getter
694 * @return last index property as boxed integer
695 */
696 public Object getLastIndexObject() {
697 return lastIndex;
698 }
|