Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.sun.security.jgss.GSSUtil;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Retake2 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- Pattern pattern1 = Pattern.compile("@+[A-z]{3,}@@[A-z]+@+|#+[A-z]{3,}##[A-z]+#+");
- int count = 0;
- Matcher matcher = pattern1.matcher(input);
- while (matcher.find()) {
- count++;
- }
- System.out.printf("%d word pairs found!", count);
- System.out.println("The mirror words are:");
- System.out.println();
- }
- static boolean isPalindrome(String str) {
- // Pointers pointing to the beginning
- // and the end of the string
- int i = 0, j = str.length() - 1;
- // While there are characters toc compare
- while (i < j) {
- // If there is a mismatch
- if (str.charAt(i) != str.charAt(j))
- return false;
- // Increment first pointer and
- // decrement the other
- i++;
- j--;
- }
- // Given string is a palindrome
- return true;
- }
- }
- // Driver code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement