We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Regex 2 - Duplicate Words
Java Regex 2 - Duplicate Words
Sort by
recency
|
392 Discussions
|
Please Login in order to post a comment
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class DuplicateWords {
}
import java.util.Scanner; import java.util.regex.Matcher; import java.util.regex.Pattern;
public class DuplicateWords {
public static void main(String[] args) {
} }
import java.util.Scanner; import java.util.regex.Pattern;
public class DuplicateWords {
This is the code I am getting the o/p same as shown but still getting the wrong answer.
}
With this code I got the same expected results except for a mysterious character at the end of the last test case. It is neither a whitespace or unprintable char. It makes no sense for me.
String regex = "\b(\w+)(\s+\1\b)+"; Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);