正規表現や置換の区切り文字を選べる
投稿:2017-07-17
LinuxとWindowsで動作確認済。
#!/usr/local/bin/perl -w use utf8; use warnings; use strict; use open IO => ":utf8"; use Encode::Locale; binmode STDOUT, ":encoding(console_out)"; $| = 1; my $text = "efghogefgh\n"; print $text =~ s!hoge!fuga!r; print $text =~ s@hoge@fuga@r; print $text =~ s#hoge#fuga#r; print $text =~ s$hoge$fuga$r; print $text =~ s%hoge%fuga%r; print $text =~ s^hoge^fuga^r; print $text =~ s&hoge&fuga&r; print $text =~ s*hoge*fuga*r; print $text =~ s-hoge-fuga-r; print $text =~ s=hoge=fuga=r; print $text =~ s+hoge+fuga+r; print $text =~ s|hoge|fuga|r; print $text =~ s\hoge\fuga\r; print $text =~ s~hoge~fuga~r; print $text =~ s`hoge`fuga`r; print $text =~ s:hoge:fuga:r; print $text =~ s;hoge;fuga;r; print $text =~ s"hoge"fuga"r; print $text =~ s'hoge'fuga'r; print $text =~ s,hoge,fuga,r; print $text =~ s.hoge.fuga.r; print $text =~ s?hoge?fuga?r; print $text =~ s/hoge/fuga/r;
efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh efgfugafgh