// Split URL into protocol, domain, port and URI
Pattern pattern = ~/(https?:\/\/)([^:^\/]*)(:\d*)?(.*)?/
Matcher matcher = pattern.matcher url
matcher.find()
String protocol = matcher.group 1
String domain = matcher.group 2
String port = matcher.group 3
String uri = matcher.group 4
Showing posts with label RegEx. Show all posts
Showing posts with label RegEx. Show all posts
Split a URL into protocol, domain, port and uri using regular expressions
Posted on
by Kim
0 comments Filed Under: Groovy, Java, RegEx
Subscribe to:
Posts (Atom)