正则oc

作者: 九月_adhoc | 来源:发表于2019-03-07 16:02 被阅读0次
    NSError *error;
    

    // NSString *string =@"[@emoji_3sd@]";
    //
    // NSString *string =@"[@emoji_9@] ddsad[酷] dasdas @emoji_5@ [闪电] [闭嘴] [@emoji_5@] [@emoji_5@]";
    //
    // NSString *regulaStr = @"\[@emoji_[a-zA-Z0-9]+@\]";

    NSString *string =@"<span>手机号码&quot;15512341234&quot;</span>                <span>广东&nbsp;广州&nbsp;&nbsp;中国联通</span>";
    
    NSString *regulaStr = @"<span>手机号码&quot;(\\d{1,})&quot;</span>                <span>(.*?)&nbsp;(.*?)&nbsp;&nbsp;(.*?)</span>";
    
    
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regulaStr
                                                                           options:NSRegularExpressionCaseInsensitive
                                                                             error:&error];
    
    [regex enumerateMatchesInString:string options:0 range:NSMakeRange(0, [string length]) usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) {
        
        if(result.numberOfRanges>4){
            NSString *tel1 =[string substringWithRange:[result rangeAtIndex:1]]; //匹配文本  2匹配子文本
            NSString *tel2 =[string substringWithRange:[result rangeAtIndex:2]]; //匹配文本  2匹配子文本
            NSString *tel3 =[string substringWithRange:[result rangeAtIndex:3]]; //匹配文本  2匹配子文本
            NSString *tel4 =[string substringWithRange:[result rangeAtIndex:4]]; //匹配文本  2匹配子文本
            NSLog(@"tel------%@",tel1);
            NSLog(@"tel------%@",tel2);
            NSLog(@"tel------%@",tel3);
            NSLog(@"tel------%@",tel4);
            NSLog(@"tel------%@",tel4);
            
        }
        
        
        
    }];
    

    入库单 JHStockOrderVC JHStockTableCell
    出库单 JHStockOrderVC JHStockTableCell
    查询管理 JHStockFindVC JHStockTableCell
    商品移库 JHStockMoveVC JHStockTableCell
    盘点计划 JHInentroyListVC JHStockTableCell

    相关文章

      网友评论

          本文标题:正则oc

          本文链接:https://www.haomeiwen.com/subject/elzcpqtx.html