search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

4 answers
Q&A ios - How to replace both numbers and English in a string with *

0

I have a string that contains Chinese characters, English and numbers. I want to replace numbers and English with *. How do I do this? Usually it is a simple replacement. This requires regular expressions

Your Answer
submit

4 answers
0

Loop it over and judge the ASCII code directly. Use c syntax to compare and change characters one by one

2017-07-06 10:36:30

submit

0

Isn’t this okay?

var str = '123你好呀hehe';
console.log(str.replace(/\w/g, '*'));
2017-07-06 10:36:30

submit

0
var str = '123你好呀hehe';
console.log(str.replace(/\w|\d/gi, '*'))
2017-07-06 10:36:30

submit

0
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);

2017-07-06 10:36:30

submit

Popular tool

vc9-vc14 (32+64 bit) runtime library collection (link below)

vc9-vc14 (32+64 bit) runtime library collection (link below)

Download the collection of runtime libraries required for phpStudy installation

VC9 32-bit

VC9 32-bit

VC9 32-bit phpstudy integrated installation environment runtime library

PHP programmer toolbox full version

PHP programmer toolbox full version

Programmer Toolbox v1.0 PHP Integrated Environment

VC11 32-bit

VC11 32-bit

VC11 32-bit phpstudy integrated installation environment runtime library

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use