This is my Java code:
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String a = in.nextLine();
String pattern = "^co[a-z|A-Z]e$";
String b = a.replaceAll(pattern,"1");
System.out.print(b);
I just had to replace the word "code" or any word with "co'[a-z|A-Z]'e" with '1', but it seems to work only when the input string is "code" and nothing else
Example Input: codexxccope
Expected Output: 1xxc1
My Output: codexxccope
Example Input 2: code
My Output: 1
Any suggestions?