I have a substring in a string with the following format:
ID Number: 4D:9B:C4
I am using the following regex to match it:
ID Number: [A-Z0-9]{2}(:[A-Z0-9]{2}){2}
What I want to do is capture instances of substrings matching this regex (or just the first instance), then capture the ID number itself inside, and finally replace colons in the ID Number with spaces, so the output will be:
4D 9B C4
I've been playing around with using capture groups in replace all, surrounding my desired capture in parentheses, like this ....
String idNum = idNum.replaceAll("ID Number: ([A-Z0-9]{2}(:[A-Z0-9]{2}){2})", "$1");
But I'm not sure where to go from here or even if I'm taking the right approach. Any suggestions would be greatly appreciated.
EDIT: Perhaps I didn't phrase this the best way in the description, so I'll illustrate by example. The initial string I'm capturing is a substring within a larger string like ...
We got some text up here
ID Number: 4D:9B:C4
And also some text down here
And I want the output previously stated.