在iphone应用程序中修剪objective c中的NSstring时出现问题
我有一个类似“qytwyqteqe”的字符串,我只想要qytwyqteqe,不想要符号“” 我试着用下面的代码来修剪这个字符串,但是它的给出错误,任何人都可以帮我,请提前修改在iphone应用程序中修剪objective c中的NSstring时出现问题,iphone,objective-c,nsstring,trim,Iphone,Objective C,Nsstring,Trim,我有一个类似“qytwyqteqe”的字符串,我只想要qytwyqteqe,不想要符号“” 我试着用下面的代码来修剪这个字符串,但是它的给出错误,任何人都可以帮我,请提前修改 [[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@""" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames lengt
[[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@""" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
its giving error for this one @"""
error: missing terminating ""
编辑:
实际上我有一个这样的数组
arrConvertedDirNames:(
"(\n \"(\\n \\\"Sudha-feb16-2011-02.30PM\\\"\\n)\"",
"\n \"Tharanga-jan16-2011-10.30AM\"\n)\n"
)
我做了以下替换来删除转义序列
NSMutableString *strTrimmedDownloadedDirNames = [NSMutableString stringWithFormat:@"%@",[arrDownloadedDirNames objectAtIndex:0]];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\\\"" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\n" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\n \"" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\"\n" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\\n" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@")" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"(" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@")\" " withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\"" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@" " withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
[strTrimmedDownloadedDirNames replaceOccurrencesOfString:@"\"" withString:@" " options:NSLiteralSearch range:NSMakeRange(0, [strTrimmedDownloadedDirNames length])];
now am getting this array
arrConvertedDirNames:(
"Sudha-feb16-2011-02.30PM",
"Tharanga-jan16-2011-10.30AM"
)
但是这个数组应该是这样的
arrConvertedDirNames:(
Sudha-feb16-2011-02.30PM ,
Tharanga-jan16-2011-10.30AM
)
怎样做才能使数组如此,请任何人帮我转义一下你需要的
“
,意思是:
此:replaceCurrencesofString:@“
应该是:
replaceCurrencesofString:@“\”
您需要转义“
,意思是:
此:replaceCurrencesofString:@“
应该是:replaceCurrencesofString:@“\”
be小心地返回一个新字符串,该字符串由从给定字符集中包含的接收方字符的两端删除而成
be小心地返回一个新字符串,该字符串通过从给定字符集中包含的接收方字符的两端删除而生成。“\”应用作“转义字符”。“\”应用作“转义字符”。
NSCharacterSet *charterSet = [NSCharacterSet characterSetWithCharactersInString:@"""];
stringWithoutCurrentSymbol = [stringWithAnySimbols stringByTrimmingCharactersInSet:charterSet];