Skip to content

Instantly share code, notes, and snippets.

@bdkosher
Created August 15, 2013 14:25
Show Gist options
  • Save bdkosher/6241234 to your computer and use it in GitHub Desktop.
Save bdkosher/6241234 to your computer and use it in GitHub Desktop.
Quick and dirty methods for cleaning URLs represented as Strings using String methods.
// Clean up double slashes
// uses negative lookbehind pattern (?<!text)
def input = 'http://host//path/with//some/segments//double//slashed'
assert input.replaceAll("(?<!\\:)//", "/") == 'http://host/path/with/some/segments/double/slashed'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment