M
magix
Dear Guru,
I have been thinking hard on how to token based on demiliter after certain
position.
Example, I have list of possible string below, and the the delimiter is "1"
with the rules below
- if the 5th character is "1", then it is delimiter
elseif the 7th character is "1", then it is delimiter
else
this string is not a valid string
NE341LCBAA35
NE311LCBAA35
NE141LCBAA35
NE31341LCBAA35
I have code:
strcpy(szPrefix,strtok(token,"1\n"));
strcpy(szSuffix,strtok(NULL,"1\n"));
but only able to detect the 1st occurence of "1", and treat it as delimiter,
based on the rules above, this is not valid if has string like NE311LCBAA35.
What I want to achieve is: If I have string NE311LCBAA35, my delimiter will
be the 5th "1", and my
szPrefix = "NE31"
szSuffix = "LCBAA35"
Could you share with me on how to achieve above rules ?
Many thanks.
P/S: this is not school homeworks or anything. I'm a working adult, just my
personal interest in programming.
Regards.
I have been thinking hard on how to token based on demiliter after certain
position.
Example, I have list of possible string below, and the the delimiter is "1"
with the rules below
- if the 5th character is "1", then it is delimiter
elseif the 7th character is "1", then it is delimiter
else
this string is not a valid string
NE341LCBAA35
NE311LCBAA35
NE141LCBAA35
NE31341LCBAA35
I have code:
strcpy(szPrefix,strtok(token,"1\n"));
strcpy(szSuffix,strtok(NULL,"1\n"));
but only able to detect the 1st occurence of "1", and treat it as delimiter,
based on the rules above, this is not valid if has string like NE311LCBAA35.
What I want to achieve is: If I have string NE311LCBAA35, my delimiter will
be the 5th "1", and my
szPrefix = "NE31"
szSuffix = "LCBAA35"
Could you share with me on how to achieve above rules ?
Many thanks.
P/S: this is not school homeworks or anything. I'm a working adult, just my
personal interest in programming.
Regards.