Hi guys,
I wanted to know if theres a single method or way that will help me replace strings for specific characters.
"THIS IS MALE DUDE"
like MALE - M FEMALE - F CHILD - P
The longer way out is this..
All the strings to be replaced are in an NSDictionary with Keys as strings to be replaced and value as the replaced string.
THis is kinda complicated as the NSDictionary is pretty big.
One suggestion is to loop through the NSDictionary for the key that matches in the main string. "THIS IS MALE DUDE". If it contains, then replace it.
THis could be a long process of usage,
Instead, i was thinking if i used a tag '$' like "THIS IS $MALE DUDE".
THen i could do a local search of the string, if it contains $ then grab that word and replace it with 'M'. Is this a better way or makes no difference??
Now the problem is, how do I grab the word if it starts with '$'.
any helps appreciated guys
I wanted to know if theres a single method or way that will help me replace strings for specific characters.
"THIS IS MALE DUDE"
like MALE - M FEMALE - F CHILD - P
The longer way out is this..
Code:
[str stringByreplacingOccurencesOfString:@"MALE" withString:@"M"];
[str stringByreplacingOccurencesOfString:@"FEMALE" withString:@"F"];
[str stringByreplacingOccurencesOfString:@"CHILD" withString:@"P"];
All the strings to be replaced are in an NSDictionary with Keys as strings to be replaced and value as the replaced string.
THis is kinda complicated as the NSDictionary is pretty big.
One suggestion is to loop through the NSDictionary for the key that matches in the main string. "THIS IS MALE DUDE". If it contains, then replace it.
THis could be a long process of usage,
Instead, i was thinking if i used a tag '$' like "THIS IS $MALE DUDE".
THen i could do a local search of the string, if it contains $ then grab that word and replace it with 'M'. Is this a better way or makes no difference??
Now the problem is, how do I grab the word if it starts with '$'.
any helps appreciated guys