在iOS中按常规模式搜索

问题描述 投票:0回答:1

尝试使用正则表达式搜索bbcode样式的标签:

例如,我需要[user=1]John Dow[/user]和常规:[[user=[0-9]+].*?[/user]]但是无法收到所需的结果。

objective-c swift regex nsregularexpression
1个回答
0
投票

删除外部的一对括号并逸出文字括号(与字符范围括号不同)

let pattern = "\\[user=[0-9]+\\].*?\\[/user\\]"
© www.soinside.com 2019 - 2024. All rights reserved.