NSString *content = @"哈哈哈哈test哈t123哈哈哈哈"; NSLog(@"替换前--- %@",content); NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:@"[a-zA-Z0-9]" options:0 error:nil]; content = [regularExpression stringByReplacingMatchesInString:content options:0 range:NSMakeRange(0, content.length) withTemplate:@"*"]; NSLog(@"替换后--- %@",content);