This my example string
String of words in (brackets) to be (removed)
I want to remove all the words inside brackets, along with the pair of brackets, after which the string will look like this:
String of words in to be
Use reg expression to remove the string
Like following ( this @"\\(.+?\\)" is the regexp for string between ( and ) )
NSMutableString *str = [@"String of words in (brackets) to be (removed)" mutableCopy];
NSRegularExpression *regex = [NSRegularExpression
regularExpressionWithPattern:@"\\(.+?\\)"
options:NSRegularExpressionCaseInsensitive
error:NULL];
[regex replaceMatchesInString:str
options:0
range:NSMakeRange(0, [str length])
withTemplate:@""];
you can split string on space bases then after you take array index..and combined that string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With