30. Extracting URL parts

This problem is also suited to being solved using regular expressions. Finding a regular expression that could match any URL is, however, a difficult task. The purpose of this exercise is to help you practice your skills with the regex library, and not to find the ultimate regular expression for this particular purpose. Therefore, the regular expression used here is provided only for didactic purposes.

You can try regular expressions using online testers and debuggers, such as https://regex101.com/. This can be useful in order to work out your regular expressions and try them against various datasets.

For this task we will consider that a URL has the following parts: protocol and domain are mandatory, and port,

Get The Modern C++ Challenge now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.