Skip to content

Instantly share code, notes, and snippets.

@tomisacat
Last active August 29, 2015 14:03
Show Gist options
  • Save tomisacat/dd53c6b37e694e35feda to your computer and use it in GitHub Desktop.
Save tomisacat/dd53c6b37e694e35feda to your computer and use it in GitHub Desktop.
NSString *pattern = @"([\\.\\+\\(\\)\\-\\_\\s])";
NSRegularExpression *re = [NSRegularExpression regularExpressionWithPattern:pattern options:NSRegularExpressionCaseInsensitive error:nil];
NSString *replaced = [re stringByReplacingMatchesInString:phoneNumber options:0 range:NSMakeRange(0, [phoneNumber length]) withTemplate:@""];
NSLog(@"%@", replaced);
@tomisacat
Copy link
Author

将电话号码中的空格、括号、加号、连字符、点号和下划线去掉
In English: remove white space character,parentheses,hyphen,underline,plus character

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment