has Repeat by Regex - Java java.util.regex

Java examples for java.util.regex:Match Word

Description

has Repeat by Regex

Demo Code


//package com.java2s;

import java.util.regex.Pattern;

public class Main {
    private static Pattern PATTERN_REPEAT = Pattern.compile(".*(.).*\\1.*");

    public static boolean hasRepeat(String repeat) {
        if (repeat == null)
            return false;
        else/*from  w  w  w  .j a  v a  2s. c  o  m*/
            return PATTERN_REPEAT.matcher(repeat).matches();
    }
}

Related Tutorials