views:

827

answers:

3

I parse an XML file with objective-c for Iphone. After parsing the result string variable got an enter character. How can strip it off from the string.

Thank to everybody.

+8  A: 

I believe that the following snippet will do the trim you want.

NSString *foo = @"THis is foo\r";
NSString *bar = [foo stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
Jack Cox
A: 

You may also find NSString regular expression additions useful. You could quickly replace "\r" characters with nothing, to strip them from your document.

Alex Reynolds
A: 

The posting above mentions the use of RegexKit in the iphone.

In fact you need to use RegexKitLite on the iPhone and link it against the, unsupported, icu library.

RegexKit is not available for the iPhone.

Dean Smith