开发者

How to remove a specific set of characters from a string using regular expression in PERL

开发者 https://www.devze.com 2023-01-09 08:06 出处:网络
1)For example::I have a $string =\"abc hell_+o w343r2d -000 rebotin\".Using search pattern and regular expression is there any way to remove or chop -000 from the string in PERL.

1)For example::I have a $string ="abc hell_+o w343r2d -000 rebotin".Using search pattern and regular expression is there any way to remove or chop -000 from the string in PERL. 2)I want to begin learning regular expression with examples in simple means.Which is the best tutorial to st开发者_StackOverflowart with???


$string = "foobar";
$string =~ s/bar/baz/g;

print $string would then yield "foobaz"

the s/foo/bar/g syntax is called search and replace. The first item is the thing to search for, second item is the thing to replace it with.

in your case, you'd want the replace clause to be empty for removing things. $string =~ s/-000//g would remove -000 completely.

0

精彩评论

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

关注公众号