Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Denarius

macrumors 6502a
Original poster
Feb 5, 2008
690
0
Gironde, France
This is the command and response I'm interested in dealing with:

Code:
PennyMBP:~ adam$ lpstat -v
device for Brother_HL_1650_1670N_series___PennyG5: tea4cups:mdns://Brother%20HL-1650_1670N%20series%20%40%20PennyG5._ipp._tcp.local
device for Canon_iP4500_series___PennyG5: tea4cups:mdns://Canon%20iP4500%20series%20%40%20PennyG5._ipp._tcp.local.
device for EPSON_AL_C900___PennyG5: tea4cups:mdns://EPSON%20AL-C900%20%40%20PennyG5._ipp._tcp.local

The reason I want this is I want to take the data, get rid of the 'device for.... [printername]: ' and just return the device URI for my printer object. Problem is I've scoured through the documentation for NSString and NSMutableString and was astounded to find nothing at all relating to regular expressions. Can anyone point me in the right direction with regard to a method for chopping off the bit of the string before the URI?
 

Denarius

macrumors 6502a
Original poster
Feb 5, 2008
690
0
Gironde, France
http://regexkit.sourceforge.net/#RegexKitLite that or searching for the first ":" and make a substring.

So going with your second suggestion it would be something like(?):

Code:
NSRange *rangeToRemove=[textToManipulate rangeOfString:@":"];
//move the location one on from the colon to the following empty space
rangeToRemove.location++;
//swap the location over to the length
rangeToRemove.length=rangeToRemove.location;
//set starting point at start of the string.
rangeToRemove.location=0;
NSString *manipulatedString=[stringToManipulate stringByReplacingCharactersInRange:rangeToRemove withString:@""];
 

Denarius

macrumors 6502a
Original poster
Feb 5, 2008
690
0
Gironde, France
Actually, just been browsing through that RegexKit that you mentioned. Looks like it'll be very useful. Thanks for the heads up.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.