Groovy web console

subscribe to the feed Subscribe
to this

Remove set of characters from String using regex

Published 8 months ago by Mak with tags regex matches replaceAll
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
String request="http://localhost:8080/providerReviews?from=Provider&providerId=170&lang=fr"
println request
String langRegex="(.*)&lang=[a-z]{2}(.*)"
request= request.replaceAll('&lang=[a-z]{2}','')
println "Matched"
println "Not Matched"
println request