0

I have two regular expressions which looks up a url and determines if the URL is a silverlight video url

  1. URL should have at least one of these extensions any where .isma, .ismv, .isml

    Regex: .ism(a|v|l)

and

  1. URL should have the string "/QualityLevels({bitrate})/Fragments(audio={start-time})"

    Regex: /QualityLevels(\d+)/Fragments(\b(audio|video|text)\b=\d+)

How do I combine these two strings into one and make sure that both the conditions are satisfied?

is_silverlight_livestream_url(const char *url)
{
    /*  expecting something that ends with
     *      "xxx.isml/QualityLevels(<bitrate>)/Fragments(<type>=<timecode>)"
     *  on-demand streams have the extension ".ism" instead of ".isml"
     */
    static boost::regex regex(my_regex_str);
    try {
        if (boost::regex_match(url, regex) == true) {
            return true;
        }
    } catch (std::runtime_error e) {
    }
    return false;
}

Santhosh

Santhosh
  • 891
  • 3
  • 12
  • 31

1 Answers1

0

You would have something like this, where you look for one string, followed by (optional) extra characters (you could be more specific if you know how this URL should look) and then the file extension at the end:

/QualityLevels(\d+)/Fragments(\b(audio|video|text)\b=\d+)(.+?)?.ism(a|v|l)
Ross McLellan
  • 1,872
  • 1
  • 15
  • 19
  • Hi Ross,These are my URLs
     /PRCSTest1.isml/Events(2013_6_3_23_19_41_968)/QualityLevels(64000)/Fragments(audio=1120130612) /live/192.168.10.109_130312210620830hi/QualityLevels(64000)/Fragments(audio=86636270000)/ProxySessions(240022624).isma /live/192.168.10.109_130312210620830hi/QualityLevels(448000)/Fragments(video=86674890000)/ProxySessions(240022624).ismv 
    – Santhosh Apr 01 '13 at 22:14
  • ,These are my URLs `/PRCSTest1.isml/Events(2013_6_3_23_19_41_968)/QualityLevels(64000)/Fragments(audio=1120130612)` `/live/192.168.10.109_130312210620830hi/QualityLevels(64000)/Fragments(audio=86636270000)/ProxySessions(240022624).isma` `/live/192.168.10.109_130312210620830hi/QualityLevels(448000)/Fragments(video=86674890000)/ProxySessions(240022624).ismv` , the regex you suggested doesnot work on all of these URLs. – Santhosh Apr 01 '13 at 22:20