//
//  NSString+RegularString.m
//  Gengmei
//
//  Created by 汪俊 on 2018/2/1.
//  Copyright © 2018年 更美互动信息科技有限公司. All rights reserved.
//

#import "NSString+RegularString.h"

@implementation NSString (RegularString)
/**
 关键字 正则判断
 */
- (NSString *)regularPattern:(NSArray *)keys{
    NSMutableString *pattern = [[NSMutableString alloc]initWithString:@"(?i)"];
    
    for (NSString *key in keys) {
        [pattern appendFormat:@"%@|",key];
    }
    
    return pattern;
}

- (NSString *)numberToString {
    NSInteger num = self.integerValue;
    if (num > 0 && num < 10000) {
        return self;
    } else if (num >= 10000) {
        return [NSString stringWithFormat:@"%ld.%.0f万", num / 10000, ceilf(num % 10000 / 1000.0)];
    } else {
        return @"0";
    }
}

- (NSString *)numberToWString {
    NSInteger num = self.integerValue;
    if (num > 0 && num < 10000) {
        return self;
    } else if (num >= 10000) {
        return [NSString stringWithFormat:@"%ldw+", num / 10000];
    } else {
        return @"";
    }
}

- (NSString *)numberTo99String {
    NSInteger num = self.integerValue;
    if (num > 0 && num < 100) {
        return self;
    } else if (num > 99) {
        return [NSString stringWithFormat:@"99+"];
    } else {
        return @"";
    }
}
@end

