正则表达式中如何替换“/”
正则表达式中如何替换“/”?
[解决办法]
my $s = '/ ';
$s =~ s{/}{any thing};
[解决办法]
Python:
def replace_slash(s, repl):
____return s.replace( '/ ', repl)
Python re:
import re
def replace_slash(s, repl):
____return re.sub(r '/ ', repl, s)
Perl
sub replace_slash {
my $s = shift;
$s =~ s#/#$_[0]#ge;
return $s;
}
print replace_slash( 'abc/def ', ': '). "\n ";