Groovy 两个字段之间的任何字符串的正则表达式

Groovy regex for any string between two fields

我正在使用 groovy 正则表达式: notification.ietf-restconf:notification.my-pma-device-notification:device-notification.device-notification.notification.~/.[A-Za-z]$/.entity-ref* 对于通知和实体引用之间的任何字符串,但它不起作用。

这两个字段之间存在的任何字符串的正则表达式应该是什么 (groovy)?

字符串中有一些“通知”,假设您指的是最后一个 'device-notification.notification'?

以下将至少捕获字符串之间的一个字符。

def str = '''device-notification.device-notification.notification.CONTAINER-NAME.entity-ref'''  

def group = ( str =~ /(?<=device-notification\.notification\.)(.+)(?=\.entity-ref)/ ) 

assert 1 == group.count
assert 'CONTAINER-NAME' == group[0][0]​