Groovy 按模板分析文本中的数据

Groovy 按模板分析文本中的数据,groovy,Groovy,有没有一种方法可以从知道其模板的字符串中获取数据? 我是说,比如说 def template = "${person} came up with the idea to collect ${item}." def text = "Peter came up with the idea to collect coins." 然后检索Peter和coins?如果模板是groovy字符串(GString),则可以使用getStrings()和getValues()方法访问它的每个部分 请参见但它如何

有没有一种方法可以从知道其模板的字符串中获取数据? 我是说,比如说

def template = "${person} came up with the idea to collect ${item}."
def text = "Peter came up with the idea to collect coins."

然后检索
Peter
coins

如果模板是groovy字符串(
GString
),则可以使用
getStrings()
getValues()
方法访问它的每个部分


请参见

但它如何连接模板和文本?我需要从文本中提取数据(不是从模板中而是通过模板)。