Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 13 lines (10 sloc) 0.44 kB
#!/usr/bin/env groovy
String myPath = '/samples/music/search.php?parms=none'
String regex = '((\\w*/)*)((\\w*)(\\.php)?)(\\?.*)?'
String replacement = '$1$4.gtpl'
String result = myPath.replaceFirst(regex, replacement);
println "myPath = ${myPath}"
println "result = ${result}"
// use replaceFirst() when the init param "resource.name.replace.all"
// is set to false, replaceAll() otherwise
assert result == '/samples/music/search.gtpl'
Jump to Line
Something went wrong with that request. Please try again.