, , (, , , )
def tests = [
[input:'groovyVersion', expected:'Version'],
[input:'groovy', expected:''],
[input:'spock', expected:'spock'],
[input:'library-groovy', expected:'library'],
[input:'a-groovy-b', expected:'ab'],
[input:'groovy-library', expected:'library']
]
tests.each {
assert it.input.replaceAll(/\W?groovy\W?/, '') == it.expected
}
You can add this to metaClass from the line
String.metaClass.stripGroovy = { -> delegate.replaceAll(/\W?groovy\W?/, '') }
then do:
assert 'library-groovy'.stripGroovy() == 'library'
source
share