java.util.regex
Class Matcher

java.lang.Object
  extended by java.util.regex.Matcher
All Implemented Interfaces:
MatchResult

public class Matcher
extends java.lang.Object
implements MatchResult


Method Summary
 Matcher appendReplacement(java.lang.StringBuffer sb, java.lang.String r)
           
 java.lang.StringBuffer appendTail(java.lang.StringBuffer sb)
           
 int end()
           
 int end(int i)
           
 boolean find()
           
 boolean find(int idx)
           
 java.lang.String group()
           
 java.lang.String group(int i)
           
 int groupCount()
           
 boolean lookingAt()
           
 boolean matches()
          Determine whether a match was found in the string.
 Pattern pattern()
          Report the Pattern that this Matcher is supposed to use.
static java.lang.String quoteReplacement(java.lang.String r)
          Function that may be helpful when calling replaceAll, replaceFirst, etc.
 java.lang.String replaceAll(java.lang.String r)
          Apply the same replacement text to all matches in the target string.
 java.lang.String replaceFirst(java.lang.String r)
           
 Matcher reset()
           
 Matcher reset(java.lang.CharSequence newseq)
           
 int start()
           
 int start(int i)
           
 MatchResult toMatchResult()
          The intent on this function in the Sun Java API seems to be to return an immutable object of some private class.
 java.lang.String toString()
           
 Matcher usePattern(Pattern pat)
          Change what pattern this Matcher is using.
 

Method Detail

pattern

public Pattern pattern()
Report the Pattern that this Matcher is supposed to use.


usePattern

public Matcher usePattern(Pattern pat)
Change what pattern this Matcher is using. This was not present in Sun Java 1.4 (added in 1.5).


toMatchResult

public MatchResult toMatchResult()
The intent on this function in the Sun Java API seems to be to return an immutable object of some private class. I have never used that feature; if you want it, you are welcome to write said class.

Returns:
this Matcher

reset

public Matcher reset()

reset

public Matcher reset(java.lang.CharSequence newseq)

group

public java.lang.String group()
Specified by:
group in interface MatchResult

group

public java.lang.String group(int i)
Specified by:
group in interface MatchResult

start

public int start()
Specified by:
start in interface MatchResult

start

public int start(int i)
Specified by:
start in interface MatchResult

end

public int end()
Specified by:
end in interface MatchResult

end

public int end(int i)
Specified by:
end in interface MatchResult

groupCount

public int groupCount()
Specified by:
groupCount in interface MatchResult

matches

public boolean matches()
Determine whether a match was found in the string. In the Sun Java implementation, it is necessary to call one of the following methods before retrieving any information about a possible match: In this implementation, Pattern.Matcher() creates a Matcher that is already trying to match in the first possible place in the target string.


find

public boolean find()

find

public boolean find(int idx)

lookingAt

public boolean lookingAt()

quoteReplacement

public static java.lang.String quoteReplacement(java.lang.String r)
Function that may be helpful when calling replaceAll, replaceFirst, etc.


replaceAll

public java.lang.String replaceAll(java.lang.String r)
Apply the same replacement text to all matches in the target string. Same idea as perl's s///g.


replaceFirst

public java.lang.String replaceFirst(java.lang.String r)

appendReplacement

public Matcher appendReplacement(java.lang.StringBuffer sb,
                                 java.lang.String r)

appendTail

public java.lang.StringBuffer appendTail(java.lang.StringBuffer sb)

toString

public java.lang.String toString()