| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> perl >> Perl zhong de zheng ze biao da shi

Perl zhong de zheng ze biao da shi

2008-05-21 09:45:29 编辑來源:互联网 评论
 
 
 
本文为【Perl中的正则表达式】的拼音翻译版
  1 zheng ze biao da shi de san zhong xing shi
  shou xian wo men ying gai zhi dao Perl cheng xu zhong , zheng ze biao da shi you san zhong cun zai xing shi , ta men fen bie shi :
  pi pei :m/<regexp>/ ( huan ke yi jian xie wei /<regexp>/ , lue qu m)
  ti huan :s/<pattern>/<replacement>/
  zhuan hua :tr/<pattern>/<replacemnt>/
  zhe san zhong xing shi yi ban dou he =~ huo !~ da pei shi yong ( qi zhong "=~" biao shi xiang pi pei , zai zheng tiao yu ju zhong du zuo does,"!~" biao shi bu pi pei , zai zheng tiao yu ju zhong du zuo doesn't), bing zai zuo ce you dai chu li de biao liang bian liang 。 ru guo mei you gai bian liang he =~ !~ cao zuo fu , ze mo ren wei chu li $_ bian liang zhong de nei rong 。 ju li ru xia :
  $str = "I love Perl";
  $str =~ m/Perl/; # biao shi ru guo zai $str zhong fa xian "Perl" zi fu chuan , ze fan hui "1" fou ze fan hui "0"。
  $str =~ s/Perl/BASH/; # biao shi jiang bian liang $str zhong de "Perl" zi fu chuan ti huan wei "BASH", ru guo fa sheng ci ti huan ze fan hui "1", fou ze fan hui "0"。
  $str !~ tr/A-Z/a-z/; # biao shi jiang bian liang $str zhong de suo you da xie zi mu zhuan hua wei xiao xie zi mu , ru guo zhuan hua fa sheng le ze fan hui "0", fou ze fan hui "1"。
  ling wai huan you :
  foreach (@array) { s/a/b/; } # ci chu mei ci xun huan jiang cong @array shu zu zhong qu chu yi ge yuan su cun fang zai $_ bian liang zhong , bing dui $_ jin xing ti huan chu li 。
  while (<FILE>) { print if (m/error/); } # zhe yi ju shao wei fu duo yi xie , ta jiang da yin FILE wen jian zhong suo you bao han error zi fu chuan de xing 。
  Perl de zheng ze biao da shi zhong ru guo chu xian () , ze fa sheng pi pei huo ti huan hou () nei de mo shi bei Perl jie shi qi zi dong yi ci fu gei xi tong $1, $2 ...... qing kan xia mian de li zi :
  $string = "I love perl";
  $string =~ s/(love)/<$1>/; # ci shi $1 = "love", bing qie gai ti huan de jie guo shi jiang $string bian wei "I <love> perl"
  $string = "i love perl";
  $string =~ s/(i)(.*)(perl)/<$3>$2<$1>/; # zhe li $1 = "i",$2 = " love ",$3 = "perl", bing qie ti huan hou $string bian wei "<perl> love <i>"
  ti huan cao zuo s/<pattern>/<replacement>/ huan ke yi zai mo yi jia shang e huo g shen shu , ta men de han yi fen bie wei :
  s/<pattern>/<replacement>/g biao shi ba dai chu li zi fu chuan zhong suo you fu he <pattern> de mo shi quan bu ti huan wei <replacement> zi fu chuan , er bu shi zhi ti huan di yi ge chu xian de mo shi 。
  s/<pattern>/<replacement>/e biao shi jiang ba <replacemnet> bu fen dang zuo yi ge yun suan fu , zhe ge shen shu yong de bu duo 。
  bi ru xia mian de li zi :
  $string = "i:love:perl";
  $string =~ s/:/*/; # ci shi $string="i*love:perl";
  $string = "i:love:perl";
  $string =~ s/:/*/g; # ci shi $string="i*love*perl";
  $string =~ tr/*/ /; # ci shi $string="i love perl";
  $string = "www22cgi44";
  $string =~ s/(\d+)/$1*2/e; # (/d+) dai biao $string zhong de yi ge huo duo ge shu zi zi fu , jiang zhe xie shu zi zi fu zhi xing *2 de cao zuo , yin ci zui hou $string bian cheng le "www44cgi88"。
  xia mian gei chu yi ge wan zheng de li zi :
  #!/usr/bin/perl
  print" qing shu ru yi ge zi fu chuan !\n";
  $string = <STDIN>; # <STIDN> dai biao biao zhun shu ru , hui rang shi yong zhe shu ru yi zi fu chuan
  chop($string); # jiang $string zui hou yi ge huan xing de zi fu \n shan chu diao
  if($string =~ /perl/){
  print(" shu ru de zi fu chuan zhong you perl zhe ge zi fu chuan !\n";
  }
  ru guo shu ru de zi fu chuan han you perl zhe ge zi fu chuan de hua , jiu hui xian shi hou mian de ti shi xin xi 。
  2 zheng ze biao da shi zhong de chang yong mo shi
  xia mian shi zheng ze biao da shi zhong de yi xie chang yong mo shi 。
  
  
  /pattern/
  jie guo
  
  .
  pi pei chu huan xing fu yi wai de suo you zi fu
  
  x?
  pi pei 0 ci huo yi ci x zi fu chuan
  
  x*
  pi pei 0 ci huo duo ci x zi fu chuan , dan pi pei ke neng de zui shao ci shu
  
  x+
  pi pei 1 ci huo duo ci x zi fu chuan , dan pi pei ke neng de zui shao ci shu
  
  .*
  pi pei 0 ci huo yi ci de ren he zi fu
  
  .+
  pi pei 1 ci huo duo ci de ren he zi fu
  
  {m}
  pi pei gang hao shi m ge de zhi ding zi fu chuan
  
  {m,n}
  pi pei zai m ge yi shang n ge yi xia de zhi ding zi fu chuan
  
  {m,}
  pi pei m ge yi shang de zhi ding zi fu chuan
  
  []
  pi pei fu he [] nei de zi fu
  
  [^]
  pi pei bu fu he [] nei de zi fu
  
  [0-9]
  pi pei suo you shu zi zi fu
  
  [a-z]
  pi pei suo you xiao xie zi mu zi fu
  
  [^0-9]
  pi pei suo you fei shu zi zi fu
  
  [^a-z]
  pi pei suo you fei xiao xie zi mu zi fu
  
  ^
  pi pei zi fu kai tou de zi fu
  
  $
  pi pei zi fu jie yi de zi fu
  
  \d
  pi pei yi ge shu zi de zi fu , he [0-9] yu fa yi yang
  
  \d+
  pi pei duo ge shu zi zi fu chuan , he [0-9]+ yu fa yi yang
  
  \D
  fei shu zi , qi ta tong \d
  
  \D+
  fei shu zi , qi ta tong \d+
  
  \w
  ying wen zi mu huo shu zi de zi fu chuan , he [a-zA-Z0-9] yu fa yi yang
  
  \w+
  he [a-zA-Z0-9]+ yu fa yi yang
  
  \W
  fei ying wen zi mu huo shu zi de zi fu chuan , he [^a-zA-Z0-9] yu fa yi yang
  
  \W+
  he [^a-zA-Z0-9]+ yu fa yi yang
  
  \s
  kong ge , he [\n\t\r\f] yu fa yi yang
  
  \s+
  he [\n\t\r\f]+ yi yang
  
  \S
  fei kong ge , he [^\n\t\r\f] yu fa yi yang
  
  \S+
  he [^\n\t\r\f]+ yu fa yi yang
  
  \b
  pi pei yi ying wen zi mu , shu zi wei bian jie de zi fu chuan
  
  \B
  pi pei bu yi ying wen zi mu , shu zhi wei bian jie de zi fu chuan
  
  a|b|c
  pi pei fu he a zi fu huo shi b zi fu huo shi c zi fu de zi fu chuan
  
  abc
  pi pei han you abc de zi fu chuan
  
  (pattern)
  () zhe ge fu hao hui ji zhu suo zhao xun dao de zi fu chuan , shi yi ge hen shi yong de yu fa 。 di yi ge () nei suo zhao dao de zi fu chuan bian cheng $1 zhe ge bian liang huo shi \1 bian liang , di er ge () nei suo zhao dao de zi fu chuan bian cheng $2 zhe ge bian liang huo shi \2 bian liang , yi ci lei tui xia qu 。
  
  /pattern/i
  i zhe ge shen shu biao shi hu lue ying wen da xiao xie , ye jiu shi zai pi pei zi fu chuan de shi hou , bu kao lv ying wen de da xiao xie wen ti 。
  
  ru guo yao zai pattern mo shi zhong zhao xun yi ge te shu zi fu , ru "*", ze yao zai zhe ge zi fu qian jia shang \ fu hao , zhe yang cai hui rang te shu zi fu shi xiao
  
  
  
  xia mian gei chu yi xie li zi :
  
  fan li
  shuo ming
  
  /perl/
  zhao dao han you perl de zi fu chuan
  
  /^perl/
  zhao dao kai tou shi perl de zi fu chuan
  
  /perl$/
  zhao dao jie yi shi perl de zi fu chuan
  
  /c|g|i/
  zhao dao han you c huo g huo i de zi fu chuan
  
  /cg{2,4}i/
  zhao dao c hou mian gen zhe 2 ge dao 4 ge g , zai gen zhe i de zi fu chuan
  
  /cg{2,}i/
  zhao dao c hou mian gen zhe 2 ge yi shang g , zai gen zhe i de zi fu chuan
  
  /cg{2}i/
  zhao dao c hou mian gen zhe 2 ge g, zai gen zhe i de zi fu chuan
  
  /cg*i/
  zhao dao c hou mian gen zhe 0 ge huo duo ge g , zai gen zhe i de zi fu chuan , ru tong /cg{0,1}i/
  
  /cg+i/
  zhao dao c hou mian gen zhe yi ge yi shang g, zai gen zhe i de zi fu chuan , ru tong /cg{1,}i/
  
  /cg?i/
  zhao dao c hou mian gen zhe 0 ge huo shi 1 ge g , zai gen zhe i de zi fu chuan , ru tong /cg{0,1}i/
  
  /c.i/
  zhao dao c hou mian gen zhe yi ge ren yi zi fu , zai gen zhe i de zi fu chuan
  
  /c..i/
  zhao dao c hou mian gen zhe er ge ren yi zi fu , zai gen zhe i de zi fu chuan
  
  /[cgi]/
  zhao dao fu he you zhe san ge zi fu ren yi yi ge de zi fu chuan
  
  /[^cgi]/
  zhao dao mei you zhe san ge zi fu zhong ren yi yi ge de zi fu chuan
  
  /\d/
  zhao xun fu he shu zi de zi fu , ke yi shi yong /\d+/ lai biao shi yi ge huo shi duo ge shu zi zu cheng de zi fu chuan
  
  /\D/
  zhao xun fu he bu shi shu zi de zi fu , ke yi shi yong /\D+/ lai biao shi yi ge huo shi geng duo ge fei shu zi zu cheng de zi fu chuan
  
  /\*/
  zhao xun fu he * zhe ge zi fu , yin wei * zai chang gui biao da shi zhong you ta de te shu yi si , suo yi yao zai zhe ge te shu fu hao qian jia shang \ fu hao , zhe yang cai hui rang zhe ge te shu zi fu shi xiao
  
  /abc/i
  zhao xun fu he abc de zi fu chuan er qie bu kao lv zhe xie zi fu chuan de da xiao xie
  
  3 zheng ze biao da shi de ba da yuan ze
  ru guo zai Unix zhong zeng jing shi yong guo sed、awk、grep zhe xie ming ling de hua , xiang xin dui yu Perl yu yan zhong de zheng ze biao da shi (Regular Expression) bu hui gan dao mo sheng 。Perl yu yan you yu you zhe ge gong neng , suo yi dui zi fu chuan de chu li neng li fei chang qiang 。 zai Perl yu yan de cheng xu zhong , jing chang ke yi kan dao zheng ze biao da shi de yun yong , zai CGI cheng xu she ji zhong ye bu li wai 。
  zheng ze biao da shi shi chu xue Perl de nan dian suo zai , bu guo zhi yao yi dan zhang wo qi yu fa , ni jiu ke yi yong you ji hu wu xian de mo shi pi pei neng li , er qie Perl bian cheng de da bu fen gong zuo dou shi zhang wo chang gui biao da shi 。 xia mian gei da jia jie shao ji tiao zheng ze biao da shi shi yong guo cheng zhong de 8 da yuan ze 。
  zheng ze biao da shi zai dui fu shu ju de zhan dou zhong ke xing cheng pang da de lian meng —— zhe chang chang shi yi chang zhan zheng 。 wo men yao ji zhu xia mian ba tiao yuan ze :
  · yuan ze 1: zheng ze biao da shi you san zhong bu tong xing shi ( pi pei (m/ /), ti huan (s/ / /eg) he zhuan huan (tr/ / /))。
  · yuan ze 2: zheng ze biao da shi jin dui biao liang jin xing pi pei ( $scalar =~ m/a/; ke yi gong zuo ; @array =~ m/a/ jiang ba @array zuo wei biao liang dui dai , yin ci ke neng bu hui cheng gong )。
  · yuan ze 3: zheng ze biao da shi pi pei yi ge gei ding mo shi de zui zao de ke neng pi pei 。 que sheng shi , jin pi pei huo ti huan zheng ze biao da shi yi ci ( $a = 'string string2'; $a =~ s/string/ /; dao zhi $a = 'string 2')。
  · yuan ze 4: zheng ze biao da shi neng gou chu li shuang yin hao suo neng chu li de ren yi he quan bu zi fu ( $a =~ m/$varb/ zai pi pei qian ba varb kuo zhan wei bian liang ; ru guo $varb = 'a' $a = 'as',$a =~ s/$varb/ /; deng jia yu $a =~ s/a/ /; , zhi xing jie guo shi $a = " s" )。
  · yuan ze 5: zheng ze biao da shi zai qiu zhi guo cheng zhong chan sheng liang zhong qing kuang : jie guo zhuang tai he fan xiang yin yong : $a=~ m/pattern/ biao shi $a zhong shi fou you zi chuan pattern chu xian ,$a =~ s/(word1)(word2)/$2$1/ ze “ tiao huan ” zhe liang ge dan ci 。
  · yuan ze 6: zheng ze biao da shi de gai xin neng li zai yu tong pei fu he duo chong pi pei yun suan fu yi ji ta men ru he cao zuo 。$a =~ m/\w+/ pi pei yi ge huo duo ge dan ci zi fu ;$a =~ m/\d/" pi pei ling ge huo duo ge shu zi 。
  · yuan ze 7: ru guo yu pi pei bu zhi yi ge zi fu ji he ,Perl shi yong "|" lai zeng jia ling huo xing 。 ru guo shu ru m/(cat|dog)/ ze xiang dang yu “ pi pei zi fu chuan cat huo zhe dog。
  · yuan ze 8:Perl yong (?..) yu fa gei zheng ze biao da shi ti gong kuo zhan gong neng 。( zhe yi dian qing tong xue men ke hou kan xiang guan zi liao )
  xiang yao xue xi suo you zhe xie yuan ze ? wo jian yi da jia xian cong jian dan de kai shi , bing qie bu duan de chang shi he shi yan 。 shi ji shang ru guo xue hui le $a =~ m/ERROR/ shi zai $a zhong cha zhao zi chuan ERROR, na me ni jiu yi jing bi zai C zhe yang de di ceng yu yan zhong de dao le geng da de chu li neng li 。【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
  1 zheng ze biao da shi de san zhong xing shi    shou xian wo men ying gai zhi dao Perl cheng xu zhong , zheng ze biao da shi you san zhong cun zai xing shi , ta men fen bie shi :    pi pei :m/<regexp>/ ( huan ke yi jian xie wei /<regexp>/ , lue qu m)    ti huan :s/<pattern>/<replacement>/    zhuan hua :tr/<pattern>/<replacemnt>/    zhe san zhong xing shi yi ban dou he =~ huo !~ da pei shi yong ( qi zhong "=~" biao shi xiang pi pei , zai zheng tiao yu ju zhong du zuo does,"!~" biao shi bu pi pei , zai zheng tiao yu ju zhong du zuo doesn't), bing zai zuo ce you dai chu li de biao liang bian liang 。 ru guo mei you gai bian liang he =~ !~ cao zuo fu , ze mo ren wei chu li $_ bian liang zhong de nei rong 。 ju li ru xia :   $str = "I love Perl";   $str =~ m/Perl/; # biao shi ru guo zai $str zhong fa xian "Perl" zi fu chuan , ze fan hui "1" fou ze fan hui "0"。   $str =~ s/Perl/BASH/; # biao shi jiang bian liang $str zhong de "Perl" zi fu chuan ti huan wei "BASH", ru guo fa sheng ci ti huan ze fan hui "1", fou ze fan hui "0"。   $str !~ tr/A-Z/a-z/; # biao shi jiang bian liang $str zhong de suo you da xie zi mu zhuan hua wei xiao xie zi mu , ru guo zhuan hua fa sheng le ze fan hui "0", fou ze fan hui "1"。    ling wai huan you :   foreach (@array) { s/a/b/; } # ci chu mei ci xun huan jiang cong @array shu zu zhong qu chu yi ge yuan su cun fang zai $_ bian liang zhong , bing dui $_ jin xing ti huan chu li 。   while (<FILE>) { print if (m/error/); } # zhe yi ju shao wei fu duo yi xie , ta jiang da yin FILE wen jian zhong suo you bao han error zi fu chuan de xing 。   Perl de zheng ze biao da shi zhong ru guo chu xian () , ze fa sheng pi pei huo ti huan hou () nei de mo shi bei Perl jie shi qi zi dong yi ci fu gei xi tong $1, $2 ...... qing kan xia mian de li zi :   $string = "I love perl";   $string =~ s/(love)/<$1>/; # ci shi $1 = "love", bing qie gai ti huan de jie guo shi jiang $string bian wei "I <love> perl"   $string = "i love perl";   $string =~ s/(i)(.*)(perl)/<$3>$2<$1>/; # zhe li $1 = "i",$2 = " love ",$3 = "perl", bing qie ti huan hou $string bian wei "<perl> love <i>"    ti huan cao zuo s/<pattern>/<replacement>/ huan ke yi zai mo yi jia shang e huo g shen shu , ta men de han yi fen bie wei :   s/<pattern>/<replacement>/g biao shi ba dai chu li zi fu chuan zhong suo you fu he <pattern> de mo shi quan bu ti huan wei <replacement> zi fu chuan , er bu shi zhi ti huan di yi ge chu xian de mo shi 。   s/<pattern>/<replacement>/e biao shi jiang ba <replacemnet> bu fen dang zuo yi ge yun suan fu , zhe ge shen shu yong de bu duo 。    bi ru xia mian de li zi :   $string = "i:love:perl";   $string =~ s/:/*/; # ci shi $string="i*love:perl";   $string = "i:love:perl";   $string =~ s/:/*/g; # ci shi $string="i*love*perl";   $string =~ tr/*/ /; # ci shi $string="i love perl";   $string = "www22cgi44";   $string =~ s/(\d+)/$1*2/e; # (/d+) dai biao $string zhong de yi ge huo duo ge shu zi zi fu , jiang zhe xie shu zi zi fu zhi xing *2 de cao zuo , yin ci zui hou $string bian cheng le "www44cgi88"。    xia mian gei chu yi ge wan zheng de li zi :   #!/usr/bin/perl   print" qing shu ru yi ge zi fu chuan !\n";   $string = <STDIN>; # <STIDN> dai biao biao zhun shu ru , hui rang shi yong zhe shu ru yi zi fu chuan   chop($string); # jiang $string zui hou yi ge huan xing de zi fu \n shan chu diao   if($string =~ /perl/){   print(" shu ru de zi fu chuan zhong you perl zhe ge zi fu chuan !\n";   }    ru guo shu ru de zi fu chuan han you perl zhe ge zi fu chuan de hua , jiu hui xian shi hou mian de ti shi xin xi 。   2 zheng ze biao da shi zhong de chang yong mo shi    xia mian shi zheng ze biao da shi zhong de yi xie chang yong mo shi 。             /pattern/    jie guo         .    pi pei chu huan xing fu yi wai de suo you zi fu         x?    pi pei 0 ci huo yi ci x zi fu chuan         x*    pi pei 0 ci huo duo ci x zi fu chuan , dan pi pei ke neng de zui shao ci shu         x+    pi pei 1 ci huo duo ci x zi fu chuan , dan pi pei ke neng de zui shao ci shu         .*    pi pei 0 ci huo yi ci de ren he zi fu         .+    pi pei 1 ci huo duo ci de ren he zi fu         {m}    pi pei gang hao shi m ge de zhi ding zi fu chuan         {m,n}    pi pei zai m ge yi shang n ge yi xia de zhi ding zi fu chuan         {m,}    pi pei m ge yi shang de zhi ding zi fu chuan         []    pi pei fu he [] nei de zi fu         [^]    pi pei bu fu he [] nei de zi fu         [0-9]    pi pei suo you shu zi zi fu         [a-z]    pi pei suo you xiao xie zi mu zi fu         [^0-9]    pi pei suo you fei shu zi zi fu         [^a-z]    pi pei suo you fei xiao xie zi mu zi fu         ^    pi pei zi fu kai tou de zi fu         $    pi pei zi fu jie yi de zi fu         \d    pi pei yi ge shu zi de zi fu , he [0-9] yu fa yi yang         \d+    pi pei duo ge shu zi zi fu chuan , he [0-9]+ yu fa yi yang         \D    fei shu zi , qi ta tong \d         \D+    fei shu zi , qi ta tong \d+         \w    ying wen zi mu huo shu zi de zi fu chuan , he [a-zA-Z0-9] yu fa yi yang         \w+    he [a-zA-Z0-9]+ yu fa yi yang         \W    fei ying wen zi mu huo shu zi de zi fu chuan , he [^a-zA-Z0-9] yu fa yi yang         \W+    he [^a-zA-Z0-9]+ yu fa yi yang         \s    kong ge , he [\n\t\r\f] yu fa yi yang         \s+    he [\n\t\r\f]+ yi yang         \S    fei kong ge , he [^\n\t\r\f] yu fa yi yang         \S+    he [^\n\t\r\f]+ yu fa yi yang         \b    pi pei yi ying wen zi mu , shu zi wei bian jie de zi fu chuan         \B    pi pei bu yi ying wen zi mu , shu zhi wei bian jie de zi fu chuan         a|b|c    pi pei fu he a zi fu huo shi b zi fu huo shi c zi fu de zi fu chuan         abc    pi pei han you abc de zi fu chuan         (pattern)   () zhe ge fu hao hui ji zhu suo zhao xun dao de zi fu chuan , shi yi ge hen shi yong de yu fa 。 di yi ge () nei suo zhao dao de zi fu chuan bian cheng $1 zhe ge bian liang huo shi \1 bian liang , di er ge () nei suo zhao dao de zi fu chuan bian cheng $2 zhe ge bian liang huo shi \2 bian liang , yi ci lei tui xia qu 。          /pattern/i   i zhe ge shen shu biao shi hu lue ying wen da xiao xie , ye jiu shi zai pi pei zi fu chuan de shi hou , bu kao lv ying wen de da xiao xie wen ti 。             ru guo yao zai pattern mo shi zhong zhao xun yi ge te shu zi fu , ru "*", ze yao zai zhe ge zi fu qian jia shang \ fu hao , zhe yang cai hui rang te shu zi fu shi xiao                      xia mian gei chu yi xie li zi :             fan li    shuo ming          /perl/    zhao dao han you perl de zi fu chuan         /^perl/    zhao dao kai tou shi perl de zi fu chuan          /perl$/    zhao dao jie yi shi perl de zi fu chuan         /c|g|i/    zhao dao han you c huo g huo i de zi fu chuan         /cg{2,4}i/    zhao dao c hou mian gen zhe 2 ge dao 4 ge g , zai gen zhe i de zi fu chuan         /cg{2,}i/    zhao dao c hou mian gen zhe 2 ge yi shang g , zai gen zhe i de zi fu chuan         /cg{2}i/    zhao dao c hou mian gen zhe 2 ge g, zai gen zhe i de zi fu chuan         /cg*i/    zhao dao c hou mian gen zhe 0 ge huo duo ge g , zai gen zhe i de zi fu chuan , ru tong /cg{0,1}i/         /cg+i/    zhao dao c hou mian gen zhe yi ge yi shang g, zai gen zhe i de zi fu chuan , ru tong /cg{1,}i/         /cg?i/    zhao dao c hou mian gen zhe 0 ge huo shi 1 ge g , zai gen zhe i de zi fu chuan , ru tong /cg{0,1}i/         /c.i/    zhao dao c hou mian gen zhe yi ge ren yi zi fu , zai gen zhe i de zi fu chuan         /c..i/    zhao dao c hou mian gen zhe er ge ren yi zi fu , zai gen zhe i de zi fu chuan         /[cgi]/    zhao dao fu he you zhe san ge zi fu ren yi yi ge de zi fu chuan         /[^cgi]/    zhao dao mei you zhe san ge zi fu zhong ren yi yi ge de zi fu chuan         /\d/    zhao xun fu he shu zi de zi fu , ke yi shi yong /\d+/ lai biao shi yi ge huo shi duo ge shu zi zu cheng de zi fu chuan         /\D/    zhao xun fu he bu shi shu zi de zi fu , ke yi shi yong /\D+/ lai biao shi yi ge huo shi geng duo ge fei shu zi zu cheng de zi fu chuan         /\*/    zhao xun fu he * zhe ge zi fu , yin wei * zai chang gui biao da shi zhong you ta de te shu yi si , suo yi yao zai zhe ge te shu fu hao qian jia shang \ fu hao , zhe yang cai hui rang zhe ge te shu zi fu shi xiao         /abc/i    zhao xun fu he abc de zi fu chuan er qie bu kao lv zhe xie zi fu chuan de da xiao xie            3 zheng ze biao da shi de ba da yuan ze    ru guo zai Unix zhong zeng jing shi yong guo sed、awk、grep zhe xie ming ling de hua , xiang xin dui yu Perl yu yan zhong de zheng ze biao da shi (Regular Expression) bu hui gan dao mo sheng 。Perl yu yan you yu you zhe ge gong neng , suo yi dui zi fu chuan de chu li neng li fei chang qiang 。 zai Perl yu yan de cheng xu zhong , jing chang ke yi kan dao zheng ze biao da shi de yun yong , zai CGI cheng xu she ji zhong ye bu li wai 。    zheng ze biao da shi shi chu xue Perl de nan dian suo zai , bu guo zhi yao yi dan zhang wo qi yu fa , ni jiu ke yi yong you ji hu wu xian de mo shi pi pei neng li , er qie Perl bian cheng de da bu fen gong zuo dou shi zhang wo chang gui biao da shi 。 xia mian gei da jia jie shao ji tiao zheng ze biao da shi shi yong guo cheng zhong de 8 da yuan ze 。    zheng ze biao da shi zai dui fu shu ju de zhan dou zhong ke xing cheng pang da de lian meng —— zhe chang chang shi yi chang zhan zheng 。 wo men yao ji zhu xia mian ba tiao yuan ze :      · yuan ze 1: zheng ze biao da shi you san zhong bu tong xing shi ( pi pei (m/ /), ti huan (s/ / /eg) he zhuan huan (tr/ / /))。   · yuan ze 2: zheng ze biao da shi jin dui biao liang jin xing pi pei ( $scalar =~ m/a/; ke yi gong zuo ; @array =~ m/a/ jiang ba @array zuo wei biao liang dui dai , yin ci ke neng bu hui cheng gong )。   · yuan ze 3: zheng ze biao da shi pi pei yi ge gei ding mo shi de zui zao de ke neng pi pei 。 que sheng shi , jin pi pei huo ti huan zheng ze biao da shi yi ci ( $a = 'string string2'; $a =~ s/string/ /; dao zhi $a = 'string 2')。   · yuan ze 4: zheng ze biao da shi neng gou chu li shuang yin hao suo neng chu li de ren yi he quan bu zi fu ( $a =~ m/$varb/ zai pi pei qian ba varb kuo zhan wei bian liang ; ru guo $varb = 'a' $a = 'as',$a =~ s/$varb/ /; deng jia yu $a =~ s/a/ /; , zhi xing jie guo shi $a = " s" )。   · yuan ze 5: zheng ze biao da shi zai qiu zhi guo cheng zhong chan sheng liang zhong qing kuang : jie guo zhuang tai he fan xiang yin yong : $a=~ m/pattern/ biao shi $a zhong shi fou you zi chuan pattern chu xian ,$a =~ s/(word1)(word2)/$2$1/ ze “ tiao huan ” zhe liang ge dan ci 。   · yuan ze 6: zheng ze biao da shi de gai xin neng li zai yu tong pei fu he duo chong pi pei yun suan fu yi ji ta men ru he cao zuo 。$a =~ m/\w+/ pi pei yi ge huo duo ge dan ci zi fu ;$a =~ m/\d/" pi pei ling ge huo duo ge shu zi 。   · yuan ze 7: ru guo yu pi pei bu zhi yi ge zi fu ji he ,Perl shi yong "|" lai zeng jia ling huo xing 。 ru guo shu ru m/(cat|dog)/ ze xiang dang yu “ pi pei zi fu chuan cat huo zhe dog。   · yuan ze 8:Perl yong (?..) yu fa gei zheng ze biao da shi ti gong kuo zhan gong neng 。( zhe yi dian qing tong xue men ke hou kan xiang guan zi liao )       xiang yao xue xi suo you zhe xie yuan ze ? wo jian yi da jia xian cong jian dan de kai shi , bing qie bu duan de chang shi he shi yan 。 shi ji shang ru guo xue hui le $a =~ m/ERROR/ shi zai $a zhong cha zhao zi chuan ERROR, na me ni jiu yi jing bi zai C zhe yang de di ceng yu yan zhong de dao le geng da de chu li neng li 。
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
情人节的清纯女生(9)
情人节的清纯女生(8)
情人节的清纯女生(7)
情人节的清纯女生(6)
山东蓬莱海边组照
一探哲蚌 II
一探哲蚌 III
古长城的一角
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有