I have few strings
"abcd: 1234""abcd : 1234""abcd : 1234""abcd: 1234""abcd 1234""abcd : abcd dgdfgdf abcd dgdsfsdf"
Please help with java code to replace abcd with xyz without removing the spaces in the first 4 strings and leave the 5th one as is and the 6th one only the first instance of abcd is replaced with 1234 as the pattern to match is abcd :