开发者

regex expression to replace a string

开发者 https://www.devze.com 2023-03-02 15:16 出处:网络
I need to replace any ch开发者_如何学Caracters in the set... []*?/\\: with an empty string.Can someone post how this is done?Depends on the language you are using; but you could use (with sed)

I need to replace any ch开发者_如何学Caracters in the set...

[]*?/\:

with an empty string. Can someone post how this is done?


Depends on the language you are using; but you could use (with sed)

sed -e "s/\[\]\*\?\/\\\://g" filename


For C#

Regex.Replace(input, @"[\[\\\]*?/:]", string.Empty)


Perl: $str =~ s/.//g;

But I think you mean replacement with a Space: $str =~ s/./ /g;


For Javascript

var s = "he[ll]o? \*/ foo:bar";
var replaced = s.replace(/[[\\\]*?/:]/g, "");

?replaced
>>hello  foobar
0

精彩评论

暂无评论...
验证码 换一张
取 消