We have keys between curly brackets and want to search these keys in some string. But when we split the string like .split(" ") some punctuation stays with the string elements. We tried the "\\p{P}"
regex but it deleted the curly brackets that we need. So how do we fix this issue?
Many thanks.
String keys = " Dear {User_Name}, your process..."
List<String> bodyContent = (Arrays.asList(keys.replaceAll("\\p{P}", "").split(" ")));
After these bodyContent = {"Dear" , "User_Name" , ...}
But we want "{User_Name}"
instead of "User_Name"
or "{User_Name},"