J
J
julith2021-05-15 00:01:09
Java
julith, 2021-05-15 00:01:09

How to hide elements between < > characters in Java?

Please tell me how to write a method that would turn the information between < and > into ***
Input: Credit card number <4008 1234 5678> 8912
Output: Credit card number *** 8912
Regular expressions cannot be used. I'm trying like this:

public static String searchAndReplaceDiamonds(String text, String placeholder) {
        if (text.contains("<")) {
            if (text.contains(">")) {
                System.out.println(text + placeholder);
            }
        }return text;
    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question