tags:

views:

47

answers:

2

I'm currently making a few changes in the rTorrent source. I have the following code:

torrent::Object
apply_to_domain(const torrent::Object& rawArgs) {

 const char * url = rawArgs.as_string().c_str();
 char buffer[50];
 snprintf(buffer, 50, "URL: %s.", url);

  return std::string(buffer);
}

I need to extract the domain from url. There's a regex.h included in the source but I'm not sure if I can use that or if I need to use a different regex library.

Link to regex.h

+3  A: 

The only thing that "regex" implementation handles is the wildcard character, *. (BTW, I'm just assuming it's a wildcard, since it's the only character that's recognised and the comments seem to hint as much, but I haven't actually verified it.)

Use a proper regex library like Boost.Regex.

Marcelo Cantos
+1  A: 

// This is a hacked up whole string pattern matching. Replace with
// TR1's regex when that becomes widely available. It is intended for
// small strings.

That's not going to work for extracting the domain. Use Boost or VSCRT TR1 instead.

Franci Penov