|
-
July 19th, 1999, 02:36 PM
#1
Help I need help
CString string= "http://home.microsoft.com?RID=Report1&Date=today";
int len = string.GetLength();
while(len>0)
{
int pos = string.Find("?");
if(pos>0)
{
int i =0;
CString URL = string.Mid(0, pos);
int pos2 = string.Find("=");
int pos3 = string.Find("&");
CString string2 = string.Mid(pos2, 8);
}
}
What I want is to find what is inbetween '=' & '&'. I can find "Report1" but than I can't find "today"
If someone can show me what I'm doing wrong...
Thank you
-
July 19th, 1999, 02:51 PM
#2
Re: Help I need help
try like this :
CString string= "home.microsoft.com?RID=Report1&Date=today";
int pos = string.Find("?");
if(pos>0)
{
CString URL = string.Mid(0, pos);
string = string.Mid(pos);
len = string.GetLength();
while(len>0)
{
int pos2 = string.Find("=");
int pos3 = string.Find("&");
if (pos3 == -1)
CString string2 = string.Mid(pos2, pos3);
else
CString string2 = string.Mid(pos2);
string = string.Mid(pos3);
len = string.GetLength();
}
}
if i understand what you want to do... it will be ok..
-
July 19th, 1999, 02:55 PM
#3
Re: Help I need help
sorry.. i make 1 error in last..
now its good :
CString string= "home.microsoft.com?RID=Report1&Date=today";
int pos = string.Find("?");
if(pos>0)
{
CString URL = string.Mid(0, pos);
string = string.Mid(pos);
len = string.GetLength();
while(len>0)
{
int pos2 = string.Find("=");
int pos3 = string.Find("&");
if (pos3 != -1)
{
CString string2 = string.Mid(pos2, pos3);
string = string.Mid(pos3);
len = string.GetLength();
}
else
{
CString string2 = string.Mid(pos2);
len = 0;
}
}
}
-
July 19th, 1999, 03:00 PM
#4
Re: Help I need help
CString string = "http://home.microsoft.com?RID=Report1&Date=today";
int len = string.GetLength();
if (len > 0) // use if instead of while, or we have an infinte loop
{
int pos = string.Find("?");
if(pos>0)
{
int i =0;
CString URL = string.Mid(0, pos);
int pos2 = string.Find("=");
int pos3 = string.Find("&");
// use pos2 + 1, because CString's are 0
CString string2 = string.Mid(pos2 + 1, pos3 - pos2 - 1); based
int pos4 = string.ReverseFind('=');
CString string3 = string.Right (len - pos4 - 1);
}
}
To find the last part of the string (the "today" part), you just need to find the '=' and grap all the characters after that up to the end. I found the '=' sign by using CString::ReverseFind, & then took the remaining characters with CString::Right.
If the code doesn't make sense to you, or if you have any more questions, send me a private message or just respond to this message.
HTH
--michael
-
July 19th, 1999, 03:14 PM
#5
Re: Help I need help
This works great for that string but what if a parameter was added such that
CString string = "http://home.microsoft.com?RID=Report...y&Date2=today2";
Thanks
-
July 19th, 1999, 03:23 PM
#6
Re: Help I need help
loop like i said... but change values for .Mid()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|