美文网首页
Xcode之正则表达式搜索替换提取所需字符串

Xcode之正则表达式搜索替换提取所需字符串

作者: willokyes | 来源:发表于2018-11-14 20:51 被阅读0次

    在Xcode编辑器中 command + F 组合键打开搜索替换框:
    (RGBA为项目中自定义的宏)

    search:
    \[UIColor colorWithRed:(\d+)/255\.0 green:.(\d+)/255.0 blue:(\d+)/255\.0 alpha:(\d+)\]
    
    replace:
    RGBA($1, $2, $3, $4)
    
    
    
        //
        _shopNameLabel = [[UILabel alloc] init];
        _shopNameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
        _shopNameLabel.textColor = [UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1];
        [_backView addSubview:_shopNameLabel];
        
        //
        _shopDesciptionLabel = [[UILabel alloc] init];
        _shopDesciptionLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:13];
        _shopDesciptionLabel.textColor = [UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1];
        [_backView addSubview:_shopDesciptionLabel];
    
    
    
    
        //
        _shopNameLabel = [[UILabel alloc] init];
        _shopNameLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:16];
        _shopNameLabel.textColor = [UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1];
        [_backView addSubview:_shopNameLabel];
        
        //
        _shopDesciptionLabel = [[UILabel alloc] init];
        _shopDesciptionLabel.font = [UIFont fontWithName:@"PingFang-SC-Medium" size:13];
        _shopDesciptionLabel.textColor = [UIColor colorWithRed:49/255.0 green:49/255.0 blue:49/255.0 alpha:1];
        [_backView addSubview:_shopDesciptionLabel];
    
    

    相关文章

      网友评论

          本文标题:Xcode之正则表达式搜索替换提取所需字符串

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