views:

1168

answers:

3
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?

+2  A: 

You could use straight C stuff. Here is a regex library allowing you to use NSString. This site has a small example of use.

ongle
+2  A: 

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.

nall
+2  A: 

You could also use NSScanner on this quite easily. A quick read through this will give you all you need to know:

http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Strings/Articles/Scanners.html#//apple%5Fref/doc/uid/20000147-BCIEFGHC

sosborn