import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {
        if (Pattern.matches("HI\\b", "HI hi")) {
            System.out.println("I will not match properly");
        }
        if (Pattern.matches("HI\\b", "HI")) {
            System.out.println("I will match");
        }
        if (Pattern.compile("HI\\b").matcher("HI hi").find()) {
            System.out.println("I will match from compiled");
        }
    }
}
