开发者

regex expression to replace a string

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜