eliaskosunen/scnlib

Function requirements

Closed this issue · 1 comments

//Add a function similar to the following

std::string strRepos = "https://github.com/fmtlib/fmt";
std::string strUrl;
std::string strProto;
std::string strUserName;
std::string strProject;
scn::scan(strRepos , "{0}://{1}/{2}/{3}", strProto, strUrl, strUserName, strProject);

Now sort of possible with

std::string url = "https://github.com/eliaskosunen/scnlib";
std::string protocol, domain, username, repo;
// [^:] means accept everything but ':' -> read until ':'
// same for [^/]
auto result = scn::scan(url, "{:[^:]}://{:[^/]}/{:[^/]}/{}", protocol, domain, username, repo);
// result.empty() == true
// protocol == "https"
// domain == "github.com"
// username == "eliaskosunen"
// repo == "scnlib"

Better ergonomics for this are planned to come post-1.0.