Groovy web console

subscribe to the feed Subscribe
to this
site
groovy regex (via #groovywebconsole)
tweet this snippet Tweet
this
script

groovy regex

Published 8 months ago by mikew
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
def str = '''notification.ietf-restconf:notification.my-pma-device-notification:device-notification.device-notification.notification.CONTAINER_NAME.entity-ref'''  

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

assert 1 == group.count
assert 'CONTAINER_NAME' == group[0][0]