I have following string
task BLABLA@{taskId} "@{BLABLA.title}"
and want to extract all placeholders from it.
Placeholders are @{taskId} and @{BLABLA.title}.
I use following code:
final Pattern pattern = Pattern.compile(".*(\\@\\{.*?\\}).*");
final Matcher matcher = pattern.matcher(this.text);
while (matcher.find())
{
final String placeholder = matcher.group(1);
this.placeholders.add(placeholder);
}
The problem is that in lines with more than one placeholder (like shown above) it detects only the first placeholder.
Another example:
task BLABLA@{taskId} "@{BLABLA.title}" { start @{startDateTime}
task BLABLA2 "Text" { allocate RBLABLA2 effort @{BLABLA2.effort} } }
In this text, the code above detects
- @{BLABLA.title}
- @{startDateTime}
- @{BLABLA2.effort}
If I remove @{BLABLA.title}, then @{taskId} is detected.
How should I modify the code so that in the last example, all placeholders (@{taskId}, @{BLABLA.title}, @{startDateTime}, @{BLABLA2.effort}) are detected?