1、下载RegexKitLite,这里是链接:https://github.com/samdeane/RegexKitLite,下载后解压出来两个文件及一个例子包,需要的就是这两个文件:RegexKitLite.h,RegexKitLite.m,将其添加到工程中。

2、工程中添加libicucore.dylib frameworks库

3、现在所有的nsstring对象就可以调用RegexKitLite中的方法了。如

NSString *email = @”kkk@aaa.com”;

[email isMatchedByRegex:@"\\b([a-zA-Z0-9%_.+\\-]+)@([a-zA-Z0-9.\\-]+?\\.[a-zA-Z]{2,6})\\b”];

返回YES,证明是email格式,需要注意的是RegexKitLite用到的正则表达式和wiki上的略有区别。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-02-11
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-14
  • 2021-09-28
  • 2021-12-06
  • 2021-10-25
  • 2022-12-23
  • 2021-12-18
  • 2022-02-17
相关资源
相似解决方案