Objective-c中的正则表达式
我正在查找文本中字符串的所有匹配项,但我不明白为什么代码不起作用。在文本中,出现了两种情况 案文:Objective-c中的正则表达式,objective-c,regex,Objective C,Regex,我正在查找文本中字符串的所有匹配项,但我不明白为什么代码不起作用。在文本中,出现了两种情况 案文: <div class="infosLigneDetail pointer" onclick="javascript:toggleForfait('1');"> Alexandre OUICHER - Forfait Free illimité à 19,99 euros - 0627505460 &l
<div class="infosLigneDetail pointer" onclick="javascript:toggleForfait('1');">
Alexandre OUICHER - Forfait Free illimité à 19,99 euros - 0627505460 <input
正则表达式:
NSRegularExpression *regexpComptes = [NSRegularExpression regularExpressionWithPattern:@"(?<=javascript:toggleForfait('[0-9]');\">).*?(?=<input)" options:NSRegularExpressionSearch error:NULL];
NSArray *matchesComptes = [regexpComptes matchesInString:content
options:0
range:NSMakeRange(0, [content length])];
NSRegularExpression*regexpComptes=[NSRegularExpression regular expression with pattern:@”(您没有在toggleForfait(“[0-9]”)中逃逸(
和)
分别是(
和)
。toggleForfait\(“[0-9]”)
您需要的正则表达式是(?没有错误。找不到字符串。谢谢。也谢谢您链接到regexr.com。我知道air中的工具,但不知道链接。感谢nsregularexpressiondotmatcheslineseparator的dotall枚举值。
NSRegularExpression *regexpComptes = [NSRegularExpression regularExpressionWithPattern:@"(?<=javascript:toggleForfait('[0-9]');\">).*?(?=<input)" options:NSRegularExpressionSearch error:NULL];
NSArray *matchesComptes = [regexpComptes matchesInString:content
options:0
range:NSMakeRange(0, [content length])];