Hi i have a string and would like to extract a sub-string that matches a regex the code i currently have removes the sub-string i want it to be the only part that should be kept.
What i have, this removes it, i want to keep it:
String ticketReference = "You have been assigned to the following Support Ticket: ST-00003 bla bla bla";
ticketReference = ticketReference.replaceAll("'((ST-)[0-9]{5})", " ");
Desired Output : “ST-00003”
Thanx in Advance
You can use capture groups to do this, they are denoted
$nin Java: