Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class Matcher

  1. Object
  2. Matcher

ImplementsMatchResult

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.

Methods

public Pattern pattern()
public Matcher usePattern(Pattern newPattern)
public Matcher reset()
public Matcher reset(CharSequence input)
public Matcher region(int start, int end)
public int regionStart()
public int regionEnd()
public boolean matches()
public boolean lookingAt()
public boolean find()
public boolean find(int start)
public boolean hasMatch()Whether the last match operation found something.
public int start()
public int start(int group)
public int start(String name)
public int end()
public int end(int group)
public int end(String name)
public String group()
public String group(int group)
public String group(String name)
public int groupCount()
public MatchResult toMatchResult()The match as it is now, unaffected by what this matcher does next.
public Stream<MatchResult> 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.
public static String quoteReplacement(String s)A replacement in which $ and backslash stand for themselves.
public Matcher appendReplacement(StringBuilder sb, String replacement)
public Matcher appendReplacement(StringBuffer sb, String replacement)
public StringBuilder appendTail(StringBuilder sb)
public StringBuffer appendTail(StringBuffer sb)
public String replaceAll(String replacement)
public String replaceAll(Function<MatchResult, String> replacer)
public String replaceFirst(String replacement)
public String replaceFirst(Function<MatchResult, String> replacer)
public String toString()Returns a string representation of the object.

Inherited methods

Method details

pattern

public Pattern pattern()

usePattern

public Matcher usePattern(Pattern newPattern)

reset

public Matcher reset()

reset

public Matcher reset(CharSequence input)

region

public Matcher region(int start, int end)

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()

start

public int start(int group)

start

public int start(String name)

end

public int end()

end

public int end(int group)

end

public int end(String name)

group

public String group()

group

public String group(int group)

group

public String group(String name)

groupCount

public int groupCount()

toMatchResult

public MatchResult toMatchResult()
The match as it is now, unaffected by what this matcher does next.

results

public Stream<MatchResult> 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

public static String quoteReplacement(String s)
A replacement in which $ and backslash stand for themselves.

appendReplacement

public Matcher appendReplacement(StringBuilder sb, String replacement)

appendReplacement

public Matcher appendReplacement(StringBuffer sb, String replacement)

appendTail

public StringBuilder appendTail(StringBuilder sb)

appendTail

public StringBuffer appendTail(StringBuffer sb)

replaceAll

public String replaceAll(String replacement)

replaceAll

public String replaceAll(Function<MatchResult, String> replacer)

replaceFirst

public String replaceFirst(String replacement)

replaceFirst

public String replaceFirst(Function<MatchResult, String> replacer)

toString

public String toString()
Returns 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())