Boost logo

Boost Users :

From: yogendra karki (karki.yogendra_at_[hidden])
Date: 2006-04-28 02:56:28


hi all
i am using boost regex to check the systax of my URLs.
if i am giving a long URL then it is giving the following error:-

terminate called after throwing an instance of 'boost::bad_expression'
  what(): Memory exhausted
Aborted

and the program is aboted.
My code is this:-

#include<iostream>
#include <boost/regex/v4/regex.hpp>

bool EvaluateRegex(const std::string regularexp,std::string url){
        boost::smatch what;
        boost::regex exp(regularexp,boost::regex::extended);
        boost::regex_search(url,what,exp);
        std::string search=(std::string)what[0];
        if(search.length() == url.length())
                return true;
        else
                return false;
}

int main()
{
        std::string url;
        const std::string URLSYNTAXREGEX = "((https?|ftp)://)?(((([a-zA-Z0-9]+-?)?[a-zA-Z0-9]+)+[.]{1}[a-zA-Z0-9]+)+([:]{1}((0[0-7]+)|(0[xX][0-9a-fA-F]+)|([0-9]+))){0,1})([?/][-a-zA-Z0-9+&@#/%?=~_|!:,.; ]*)?";
        std::cout<<"enter the URL"<<std::endl;
        std::cin>>url;
        if(!EvaluateRegex(URLSYNTAXREGEX,url))
                std::cout<<"Malformed URL"<<std::endl;
        else
                std::cout<<"Well formed URL"<<std::endl;
        return 0;
}

                
---------------------------------
Love cheap thrills? Enjoy PC-to-Phone calls to 30+ countries for just 2¢/min with Yahoo! Messenger with Voice.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net