zoukankan      html  css  js  c++  java
  • ios--后台返回信息有字符串和数字组成的,如何获取*,让用户能够点击并且进行拨打?

    -(void)callPhone:(NSString*)phoneNumber{
      NSString *phoneStr=[NSString stringWithFormat:@"tel://%@",phoneNumber];
      NSURL *url=[NSURL URLWithString:phoneStr];
      [[UIApplication sharedApplication] openURL:url];
    }
    NSError *error;
        NSRegularExpression *regex = [[NSRegularExpression alloc] initWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:&error];
    
        NSLog(@"%@",error);
    
        [regex enumerateMatchesInString:string options:NSMatchingReportProgress range:NSMakeRange(0, string.length) usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) {
         if (NSMatchingReportProgress==flags) {
    
          }else{
            /**
             *  系统内置方法
             */
            if (NSTextCheckingTypePhoneNumber==result.resultType) {
              NSLog(@"%@",[string substringWithRange:result.range]);
            }
            /**
             *  长度为11位的数字串
             */
            if (result.range.length==11) {
              NSLog(@"%@",[string substringWithRange:result.range]);
            }
          }
        }];
  • 相关阅读:
    过滤textarea
    vue引用jquery
    vue_ajax插件Axios
    VeeValidate
    mongodb
    WEBGL实现--three.js笔记整理
    My SQLworkbench问题总结
    vue遇到的问题
    MYSQL使用笔记
    vue笔记
  • 原文地址:https://www.cnblogs.com/shenlaiyaoshi/p/8819079.html
Copyright © 2011-2022 走看看