All,
I have a dictionary with two keys and values. I need to extract bits and pieces from them and place them into seperate strings.
{
IP = "192.168.17.1";
desc = "VUWI-VUWI-ABC_Dry_Cleaning-R12-01";
}
That is what the dictionary looks like when I call description.
I want the new output to be like this:
NSString *IP = @"192.168.17.1";
NSString *desc = @"ABC Dry Cleaning"; //note: I need to get rid of the underscores
NSString *type = @"R";
NSString *num = @"12";
NSString *ident = @"01";
How would I achieve this?
I’ve read through the Apple developer docs on NSRegularExpression but I find it hard to understand. I’m sure once I get some help once here I can figure it out in the future, I just need to get started.
Thanks in advance.
Okay, so first, you have to get the object associated with each key:
Then, what I would do is split the string in
tempDesc, based on the character-.Then you just have to get the strings or substrings you’re interested in, and reformat them as needed:
As you can see, this works perfectly without using
NSRegularExpression.