NSString *x=@"\"/Sagar\' and \'Samir\' ";
Now, I want to remove characters between these.
\" /
\'
Intended output
x = (should have) @"and \'Samir\'"
So, Ms word give some options in find & replace, using wild card characters. ( just giving example )
Is it possible in cocoa?
I'll assume you're looking for a solution in general -- not for this particular string. You'll want to learn about regular expressions.
For regular expression support in Objective-C check out RegexKitLite. It provides category methods on NSString that support various regex matching and substitution.
You could also use NSScanner on this quite easily. A quick read through this will give you all you need to know:
You could use straight C stuff. Here is a regex library allowing you to use NSString. This site has a small example of use.
来源:https://stackoverflow.com/questions/1633331/replacing-in-nsstring-with-wildcards-regular-expressions-cocoa