objective-c - 如何编写正则表达式来过滤 {key:value} 字符串
问题描述
我有一个这样的字符串
NSString *content = @"{"year":2019,"month":12,"day":08}";
我怎样才能得到年,月和日的价值?
NSRegularExpression *testExpression = [NSRegularExpression regularExpressionWithPattern: @"(\w+):(\w+)" options:NSRegularExpressionCaseInsensitive error:nil];
NSArray *matches = [testExpression matchesInString:content
options:0
range:NSMakeRange(0, [content length])];
解决方案
推荐阅读
- android - 每次 UI 测试后如何使用“pm clear”清理应用程序数据
- java - 并行运行 maven 测试而不等待兄弟模块依赖项
- azure - 如何更改 SignUpOrSignIn 以验证 Azure AD B2C 自定义策略中登录时的自定义属性?
- java - 从java中的sftp服务器下载所有文件
- node.js - 如何在 Post 上设置选项(公共或私人)?反应,nodejs
- linux - 在 case 和 if 循环中调用函数时出现问题
- javascript - 您可以更改 googlemaps Api 路线的颜色和引脚吗?
- ruby-on-rails - Rails GQL 加载器返回子值
- javascript - SCRIPT5018:SCRIPT5018:意外的量词 - IE 的 contentDisposition.match() 的替代方法是什么?
- mysql - mysql中的多个连接与3个表