Skip to content

Instantly share code, notes, and snippets.

@klopp
Last active February 18, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klopp/794369f103e63ac50b1a21217a1f7c40 to your computer and use it in GitHub Desktop.
Save klopp/794369f103e63ac50b1a21217a1f7c40 to your computer and use it in GitHub Desktop.
static const boost::regex::flag_type rx_flags =
boost::regex_constants::perl|
boost::regex_constants::icase|
boost::regex_constants::optimize|
boost::regex_constants::collate;
static boost::regex regex_tcp_v4("((([^:]+)?(:([^@]+))?@)?([^\\/\\?:]+)(:(\\d+))?)?(\\/([^\\?]+)?)?(\\?(.*))?$", rx_flags);
static boost::regex regex_tcp_v6("((([^:]+)?(:([^@]+))?@)?(\\[[:\\da-f]+\\])(:(\\d+))?)?(\\/([^\\?]+)?)?(\\?(.*))?$", rx_flags);
static boost::regex regex_unix("((([^:]+)?(:([^@]+))?@)?([^:?:]+)(:([^\\?]+))?)?(\\?(.*))?", rx_flags);
static boost::regex regex_query("([-\\w+%]+)=([^&;]*)", rx_flags);
static boost::regex regex_is_v6("\\[[\\:\\da-f]+\\]", rx_flags);
/*
erase(0, "tcp://")
[3] user
[5] password
[6] host
[8] port
[10] dbname
[12] query
erase(0, unix://)
[3] user
[5] password
[8] socket
[10] query
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment