Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Java consecutive repeated cha
import java.util.regex.Pattern; class Rextester { public static void main(String []args) { // old regex -> Check for repetative character ->If they are more than two pattern matches System.out.println(Pattern.compile(".*(\\w).*\\1.*\\1.*").matcher("mcc@c").matches()); // New regex -> Check for any two consecutive character. -> If more than two consecutive character commes the pattern matches System.out.println(Pattern.compile(".*(\\w)\\1\\1.*").matcher("mcc@c").matches()); System.out.println(Pattern.compile(".*(\\w)\\1\\1.*").matcher("mcc@ccc").matches()); } }
run
|
edit
|
history
|
help
0
Firstproject
String is not reference Type??
Borrowing class
Speed
FizzBuzz
Piramid
3.D
2.C
Reverse a Linked List in groups of given size k
PE #3