Top > 正規表現 > . (ドット)


. (ドット)

#!/usr/bin/perl

@searchstr = ("acha-porute-piipo");
@match1 = grep /a.ha/, @searchstr;
@match2 = grep /a.porute.p/, @searchstr;
@match3 = grep /pii.../, @searchstr;

print "Content-type:text/html\n\n";

print "aとhaの間に任意の1文字がある文字列 = @match1<br>";
print "aの後に任意の1文字があり、porute、その後に任意の1文字があり、pが続く文字列 = @match2<br>";
print "piiの後に任意の3文字がある文字列 = @match3<br>";

●出力結果
aとhaの間に任意の1文字がある文字列 = acha-porute-piipo
aの後に任意の1文字があり、porute、その後に任意の1文字があり、pが続く文字列 = acha-porute-piipo
piiの後に任意の3文字がある文字列 = 

文字のスペルを忘れた時など、置き換える文字数がわかる場合に便利な機能
  郵便番号 ...-....
とか
  日付 20../../..
とか文字数がわかる場合に使用



Copyright © 2015 AchaPorutePiipo All Rights Reserved.