Struchkov Mark
ad35bf983f
All checks were successful
continuous-integration/drone/push Build is passing
744 B
744 B
tags | date | zero-link | parents | linked | article | ||
---|---|---|---|---|---|---|---|
|
2023-11-20 |
|
https://note.struchkov.dev/parsingh-url-c-pomoshchiu-rieghuliarki/ |
Разделение URL-адреса на протокол, домен, порт и URI с помощью регулярного выражения.
// Split URL into protocol, domain, port and URI
Pattern pattern = Pattern.compile("(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);