Class Matcher
java.lang.Object
com.codename1.util.regex.Matcher
- All Implemented Interfaces:
MatchResult
The same shape as java.util.regex.Matcher, over this package's Pattern.
Everything a match is read through is here -- matches, lookingAt,
find, groups by number and by name, regions, and the replacement
methods with the JDK's $1 and ${name} syntax. hitEnd,
requireEnd and the two bounds switches are not provided.
-
Method Summary
Modifier and TypeMethodDescriptionappendReplacement(StringBuffer sb, String replacement) appendReplacement(StringBuilder sb, String replacement) intend()intend(int group) intbooleanfind()booleanfind(int start) group()group(int group) intbooleanhasMatch()Whether the last match operation found something.booleanbooleanmatches()pattern()static StringA replacement in which$and backslash stand for themselves.region(int start, int end) intintreplaceAll(String replacement) replaceAll(Function<MatchResult, String> replacer) replaceFirst(String replacement) replaceFirst(Function<MatchResult, String> replacer) reset()reset(CharSequence input) results()Each match from here on, astoMatchResult()would answer it: from after the last match found, or from the start of the region when there is none.intstart()intstart(int group) intThe match as it is now, unaffected by what this matcher does next.toString()Returns a string representation of the object.usePattern(Pattern newPattern)
-
Method Details
-
pattern
-
usePattern
-
reset
-
reset
-
region
-
regionStart
public int regionStart() -
regionEnd
public int regionEnd() -
matches
public boolean matches() -
lookingAt
public boolean lookingAt() -
find
public boolean find() -
find
public boolean find(int start) -
hasMatch
public boolean hasMatch()Whether the last match operation found something. -
start
public int start()- Specified by:
startin interfaceMatchResult
-
start
public int start(int group) - Specified by:
startin interfaceMatchResult
-
start
-
end
public int end()- Specified by:
endin interfaceMatchResult
-
end
public int end(int group) - Specified by:
endin interfaceMatchResult
-
end
-
group
- Specified by:
groupin interfaceMatchResult
-
group
- Specified by:
groupin interfaceMatchResult
-
group
-
groupCount
public int groupCount()- Specified by:
groupCountin interfaceMatchResult
-
toMatchResult
The match as it is now, unaffected by what this matcher does next. -
results
Each match from here on, as
toMatchResult()would answer it: from after the last match found, or from the start of the region when there is none. The matcher is not reset, so a match already consumed is not answered again and a region stays in force.Lazy, as the JDK's is: each match is found only when the stream asks for it, so
results().limit(1)scans no further than the first. -
quoteReplacement
-
appendReplacement
-
appendReplacement
-
appendTail
-
appendTail
-
replaceAll
-
replaceAll
-
replaceFirst
-
replaceFirst
-
toString
Description copied from class:ObjectReturns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
-