Java Code Examples for java.util.regex.Matcher#useTransparentBounds()

The following examples show how to use java.util.regex.Matcher#useTransparentBounds() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmojiFactory.java    From xxl-tool with GNU General Public License v3.0 6 votes vote down vote up
/**
 * find AliasCandidate (alias) for each emoji alias
 *
 * @param input
 * @return
 */
public static List<AliasCandidate> getAliasCandidates(String input) {
    List<AliasCandidate> candidates = new ArrayList<AliasCandidate>();

    Matcher matcher = ALIAS_CANDIDATE_PATTERN.matcher(input);
    matcher = matcher.useTransparentBounds(true);
    while (matcher.find()) {
        String match = matcher.group();
        if (!match.contains("|")) {
            candidates.add(new AliasCandidate(match, match, null));
        } else {
            String[] splitted = match.split("\\|");
            if (splitted.length == 2 || splitted.length > 2) {
                candidates.add(new AliasCandidate(match, splitted[0], splitted[1]));
            } else {
                candidates.add(new AliasCandidate(match, match, null));
            }
        }
    }
    return candidates;
}
 
Example 2
Source File: EmojiParser.java    From mvvm-template with GNU General Public License v3.0 6 votes vote down vote up
private static List<AliasCandidate> getAliasCandidates(String input) {
  List<AliasCandidate> candidates = new ArrayList<AliasCandidate>();

  Matcher matcher = ALIAS_CANDIDATE_PATTERN.matcher(input);
  matcher = matcher.useTransparentBounds(true);
  while (matcher.find()) {
    String match = matcher.group();
    if (!match.contains("|")) {
      candidates.add(new AliasCandidate(match, match, null));
    } else {
      String[] splitted = match.split("\\|");
      if (splitted.length == 2 || splitted.length > 2) {
        candidates.add(new AliasCandidate(match, splitted[0], splitted[1]));
      } else {
        candidates.add(new AliasCandidate(match, match, null));
      }
    }
  }
  return candidates;
}
 
Example 3
Source File: Suggestion.java    From wpcleaner with Apache License 2.0 5 votes vote down vote up
/**
 * @param text Text to look at.
 * @return A matcher for the pattern
 */
public Matcher initMatcher(String text) {
  Matcher matcher = pattern.matcher(text);
  matcher.useAnchoringBounds(false);
  matcher.useTransparentBounds(true);
  return matcher;
}