How to check if string matches a regular expression in objective-c?

前端 未结 4 819
庸人自扰
庸人自扰 2021-01-30 21:56

since regular exressions are not supported in Cocoa I find RegexKitLite very usefull. But all examples extract matching strings.

I just want to test if a string matches

4条回答
  •  遥遥无期
    2021-01-30 22:34

    Use the -isMatchedByRegex: method.

    if([someString isMatchedByRegex:@"^[0-9a-fA-F]+:"] == YES) { NSLog(@"Matched!\n"); }
    

提交回复
热议问题