我使用 RegexKitLite 框架。
NSString *str = [NSString stringWithString:@"Welcome"];
NSString *newStr [NSString string];
//RegexKitLite.h reference.
newStr = [str stringByReplacingOccurrencesOfRegex:<How To Expression?> withString:@"?"];
我希望“欢迎”转换为 =>“W??????”;更一般地说,对于Apple
, Banana Cake
, Love
, Peach
, Watermelon
... 我想隐蔽
Apple => A????
Banana => B?????
Cake => C???
Love => L???
我制作了这些模式(仅显示 HeadLetter)...所有单词都存储在 NSMutableArray 中,所以我访问
[arr objectAtIndex:i] stringByReplacingOccurrencesOfString:<Expression> withString:@"?"];
如何比较第二个字母与正则表达式?