I have a string as follows:
"This is @awesome @dude"
From this string i want to extract awesome and dude and create a string
output==> "awesome,dude"
So my code is like following:
Matcher matcher = Pattern.compile("(?<=@)\\w+").matcher(textStr);
while (matcher.find()){
mergedStr += matcher.group() +",";
}
But this creates an artifact in the end
output==> "awesome,dude," //<-- egghh comma.. in the end
What is a better way to solve this out.