Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.w3c.dom.ls.LSOutput;
- import java.math.BigDecimal;
- import java.util.*;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- List<String> emojis = new ArrayList<>();
- // Pattern pattern2 = Pattern.compile("(:{2}[A-Z][a-z]{2,}:{2})");
- //Pattern pattern3 = Pattern.compile("(\\*{2}[A-Z][a-z]{2,}\\*{2})");
- //->tezi dvete patterns gi kombinirai v edna:
- Pattern pattern = Pattern.compile("([:]{2}|[*]{2})(?<emojy>[A-Z][a-z]{2,})(\\1)");
- Matcher matcher = pattern.matcher(input);
- int treshold = 1;
- Pattern pattern1 = Pattern.compile("[0-9]");
- Matcher matcher1 = pattern1.matcher(input);//-> direktno go vzimash ot "input"
- // String[] numbers = input.split("");
- //for (String number : numbers) { -> ne ti trqbva, ako izpolzvash while
- //izpolzvash while, za da vartish prez celiq pattern
- while (matcher1.find()) {
- treshold *= Integer.parseInt(matcher1.group(0));
- }
- // }
- //String[] emojiPickup = input.split(" ");
- // for (int i = 0; i < emojiPickup.length; i++) { -> ne ti trqbva, ako izpolzvash "while"
- while (matcher.find()) {
- emojis.add(matcher.group(0)); //-> addvash kam lista celiq pattern, toest group(0);
- }
- // }
- System.out.println(String.format("Cool threshold: %d", treshold));
- System.out.println(String.format("%s emojis found in the text. The cool ones are:", emojis.size()));
- List<String> coolEmojies = new ArrayList<>();
- for (int j = 0; j < emojis.size(); j++) {
- int sumLetter = 0;
- String element = emojis.get(j);
- for (int k = 0; k < element.length(); k++) {
- char c = element.charAt(k);
- if (Character.isLetter(c))
- sumLetter += c;
- }
- if (sumLetter > treshold) {
- System.out.println(element);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement