How to remove a specific set of characters from a string using regular expression 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.
精彩评论