Skip to content

Instantly share code, notes, and snippets.

@siritori
Forked from Santarh/regex.cpp
Created June 29, 2012 11:19
Show Gist options
  • Save siritori/3017411 to your computer and use it in GitHub Desktop.
Save siritori/3017411 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <boost/regex.hpp>
int main()
{
std::string file_path = "/foo/bar/bunny.obj";
std::string type = "unknown";
boost::regex rx_find_extension("^.*\\.(\\w+)$");
boost::smatch result;
if ( boost::regex_match( file_path, result, rx_find_extension ) )
{
type = result.str(1);
}
std::cout << type << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment