check the characters in a string
-
Hi, my string is CString STemp="PV SV MD"; I have to check whether SV or PV or MD is present in the string. if(PV is present) { certain functions; } if(SV is present) { } I have to check the presence of any two characters in a string.How can i make this? I use Find() but it gives the position but i want a particular character. Any function is there??Pls...
Anu
-
Hi, my string is CString STemp="PV SV MD"; I have to check whether SV or PV or MD is present in the string. if(PV is present) { certain functions; } if(SV is present) { } I have to check the presence of any two characters in a string.How can i make this? I use Find() but it gives the position but i want a particular character. Any function is there??Pls...
Anu
Anu_Bala wrote:
I use Find() but it gives the position but i want a particular character.
PV or SV you mentioned are strings.
Anu_Bala wrote:
I use Find() but it gives the position but i want a particular character
Whats problem with this ? if
Find
return -1, string is not present, other wise its there.Prasad Notifier using ATL
-
Hi, my string is CString STemp="PV SV MD"; I have to check whether SV or PV or MD is present in the string. if(PV is present) { certain functions; } if(SV is present) { } I have to check the presence of any two characters in a string.How can i make this? I use Find() but it gives the position but i want a particular character. Any function is there??Pls...
Anu
Hi, You can use Strcmp function to compare two strings. Regards Velayudhan
-
Hi, my string is CString STemp="PV SV MD"; I have to check whether SV or PV or MD is present in the string. if(PV is present) { certain functions; } if(SV is present) { } I have to check the presence of any two characters in a string.How can i make this? I use Find() but it gives the position but i want a particular character. Any function is there??Pls...
Anu
use
CString::Find
if your string isnt exist return value of Find is -1 else its location of string_**
**_
WhiteSky
-
Anu_Bala wrote:
I use Find() but it gives the position but i want a particular character.
PV or SV you mentioned are strings.
Anu_Bala wrote:
I use Find() but it gives the position but i want a particular character
Whats problem with this ? if
Find
return -1, string is not present, other wise its there.Prasad Notifier using ATL
Ya, i used Find(). I need one more help that is my string reads like this "pv m3 PV|| sv m3 SV||MD||" here i want to extract the string " sv m3 " from the above string.The number of characters may vary.But space and new line are used to seperate the words. Pls help me out. I think u get my point.
Anu
-
Ya, i used Find(). I need one more help that is my string reads like this "pv m3 PV|| sv m3 SV||MD||" here i want to extract the string " sv m3 " from the above string.The number of characters may vary.But space and new line are used to seperate the words. Pls help me out. I think u get my point.
Anu
Anu_Bala wrote:
here i want to extract the string " sv m3 " from the above string
Then whats problem with
Find
?Anu_Bala wrote:
The number of characters may vary
I assume you want to say, it can "SV m3 SV",is it?,
Prasad Notifier using ATL
-
Anu_Bala wrote:
here i want to extract the string " sv m3 " from the above string
Then whats problem with
Find
?Anu_Bala wrote:
The number of characters may vary
I assume you want to say, it can "SV m3 SV",is it?,
Prasad Notifier using ATL
Thanks for reply.. I explain you my need in details. First the string is like this sTemp="sub m3 PV||add m3 SV||MD||" Then i have to extract few things and i have to put in to seperate string Final String, CString StrFinal = "PV||SV||MD" I know to extract first two things i.e., sub m3 i did like this int pos2 = sTemp.Find("\n"); sTemp3 = sTemp.Mid(pos2-3); sTemp=sTemp3; here STemp = PV||add m3 SV||MD And then i have to extract add and m3. But i dont know to extract the middle add m3 . i need this thing
Anu
-
Thanks for reply.. I explain you my need in details. First the string is like this sTemp="sub m3 PV||add m3 SV||MD||" Then i have to extract few things and i have to put in to seperate string Final String, CString StrFinal = "PV||SV||MD" I know to extract first two things i.e., sub m3 i did like this int pos2 = sTemp.Find("\n"); sTemp3 = sTemp.Mid(pos2-3); sTemp=sTemp3; here STemp = PV||add m3 SV||MD And then i have to extract add and m3. But i dont know to extract the middle add m3 . i need this thing
Anu
Cant you use same logic? i.e. I assume each sub string you mentioned here is preceded by '\n'. And what does || stands for ? Is it a kind of separator ? If yes, you can use it,too. i.e. Find "||" and extarct 2 chararacters preceding it. Keep appending result string.
Prasad Notifier using ATL
-
Thanks for reply.. I explain you my need in details. First the string is like this sTemp="sub m3 PV||add m3 SV||MD||" Then i have to extract few things and i have to put in to seperate string Final String, CString StrFinal = "PV||SV||MD" I know to extract first two things i.e., sub m3 i did like this int pos2 = sTemp.Find("\n"); sTemp3 = sTemp.Mid(pos2-3); sTemp=sTemp3; here STemp = PV||add m3 SV||MD And then i have to extract add and m3. But i dont know to extract the middle add m3 . i need this thing
Anu
Do you need to get a middle a string like your example?
_**
**_
WhiteSky
-
Do you need to get a middle a string like your example?
_**
**_
WhiteSky
-
Is it possible for you to find space between add m3 or you dont have a space in your string
_**
**_
WhiteSky