How to parse Web links

Source: Internet
Author: User

Nonsense not much to say, directly on the example and code:

For link strURL = http://local/Fun=cmd_popupwindow&p1=http://www.hao123.com

According to the delimiter "&" and "=" can parse out the function name Cmd_popupwindow and parameter link http://www.hao123.com

Note: The following code, regardless of the link parameters, as long as the delimiter is & can.

1 voidUmsframebottom::analasisurl (Constcstring& strURL, TCHAR csplit, cstringarray&arycstring)2 {3 Arycstring.removeall ();4     intNPOs =0;5     intNnewpos =-1;6     intNurllen =strurl.getlength ();7     intNcsplit =1;8 9     if(nurllen<0)return ;Tenstd::vector<int>aryposition; OneNnewpos = Strurl.find (Csplit,0); A  -     if(nnewpos<0)  -     { the Arycstring.add (strurl); -         return ; -     } -      while(nnewpos>NPOs) +     { - Aryposition.push_back (nnewpos); +NPOs =Nnewpos; ANnewpos = Strurl.find (Csplit, npos+1); at     } - CString strsub1,strsub; -      for(intI=0; I<=aryposition.size (); ++i) -     { - strsub.empty (); -         if(i = =0) in         { -StrSub1 =Strurl.mid (i, aryposition[i]);  to             intSubpos = Strsub1.find (_t ("="),0); +Strsub = Strsub1.right (Strsub1.getlength ()-subpos-1); -         } the         Else *         { $             if(i = =aryposition.size ())Panax Notoginseng             { -StrSub1 = Strurl.mid (aryposition[i-1]+ncsplit); the                 intSubpos = Strsub1.find (_t ("="),0); +Strsub = Strsub1.right (Strsub1.getlength ()-subpos-1); A             } the             Else if(i>0) +             { -StrSub1 = Strurl.mid (aryposition[i-1]+ncsplit, aryposition[i]-aryposition[i-1]-ncsplit); $                 intSubpos = Strsub1.find (_t ("="),0); $Strsub = Strsub1.right (Strsub1.getlength ()-subpos-1); -             }             -         } the  -         if(Strsub.isempty ())Wuyi             Continue; the  - Arycstring.add (strsub); Wu          -     } About  $  -}

This gets the Cstringarry array arycstring will get the function name and the parameter link ...

How to parse Web links

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.