groovy regex tokenize (). function grep () no produce la respuesta esperada

Estoy intentando extraer las tags de versión de un repository git usando algunas funciones regex de groovy.

def command = "\"C:/Program Files (x86)/Git/bin/sh.exe\" --login -i -c \"git ls-remote user@mysever:myproject.git refs/tags/[vV]*?.*?.*?\"" def proc = command.execute() proc.waitFor() def str = proc.in.text def pattern = ~/^refs\/tags\/[vV][0-9]+\.[0-9]+\.[0-9]+$/ System.out.println("is everything a string? " + str.tokenize().every{ it instanceof String }) System.out.println("String: $str") System.out.println("split: ${str.split()}") System.out.println("contains refs/tags/V0.0.0?: ${str.split()*.trim().contains('refs/tags/V0.0.0')}") System.out.println("contains refs/tags/V0.0.1?: ${str.split()*.trim().contains('refs/tags/V0.0.1')}") System.out.println("grep: " + ['refs/tags/V0.0.0', 'refs/tags/V0.0.1'].grep(pattern)) System.out.println("split grep: " + str.split().grep(pattern)) System.out.println("split findAll: " + str.split().findAll{ it =~ pattern }) 

Y mi salida es esta:

 String: SHA1asdf refs/tags/V0.0.0 SHA1fdsa refs/tags/V0.0.0^{} SHA1hgfd refs/tags/V0.0.l SHA1dfgh refs/tags/V0.0.l^{} split: [SHA1asdf, refs/tags/V0.0.0, SHA1asdf, refs/tags/V0.0.0^{}, SHA1hgfd, refs/tags/V0.0.l, SHA1dfgh, refs/tags/V0.0.l^{}] contains refs/tags/V0.0.0?: true contains refs/tags/V0.0.1?: false grep: [refs/tags/V0.0.0, refs/tags/V0.0.1] split grep: [refs/tags/V0.0.0] split findAll: [refs/tags/V0.0.0] 

¿Por qué el tokenize (). Grep () no produce la respuesta esperada?

Estoy usando Groovy 2.3.6

ACTUALIZACIÓN: He agregado más resultados de testing, ver código y salida

No estoy seguro de por qué, pero su versión V0.0.1 es en realidad un carácter l y no 1 .

Si solo ejecuta la siguiente muestra (acaba de cambiar el str ), grep funcionará bien:

 def str = """ SHA1asdf refs/tags/V0.0.0 SHA1fdsa refs/tags/V0.0.0^{} SHA1hgfd refs/tags/V0.0.1 SHA1dfgh refs/tags/V0.0.1^{} """ def pattern = ~/^refs\/tags\/[vV][0-9]+\.[0-9]+\.[0-9]+$/ System.out.println("String: $str") System.out.println("tokenize: ${str.tokenize()}") System.out.println("grep: " + ["refs/tags/V0.0.0", "refs/tags/V0.0.1"].grep(pattern)) System.out.println("tokenize grep: " + str.tokenize().grep(pattern)) 

produce

 grep: [refs/tags/V0.0.0, refs/tags/V0.0.1] tokenize grep: [refs/tags/V0.0.0, refs/tags/V0.0.1]