1 #!/usr/bin/perl 2 3 use strict; 4 use warnings; 5 6 $_=' 7 8 $$ oinn &&& 9 ninq kdownc 10 aninp 11 kkkk'; 12 13 if (/(.*)k/){print "$1 ";}else{print "no match ";} 14 15 # kkk 16 17 if (/^n(.*)/m){print "$1 ";}else{print "no match ";} 18 19 #inq kdownc 20 21 if (/(.*n.n.*)/){print "$1 ";}else{print "no match ";} 22 23 #no match 24 25 if (/.*(Bn.nB).*/){print "$& and $1 ";}else{print "no match ";} 26 27 #aninp and nin 28 29 if (/w*(i)w*/){print "$& and $1 and $` and $' ";}else{print "no match ";} 30 31 #oinn and i and 32 # 33 # $$ and &&& 34 35 36 my $new_words = 37 'sewfbiurev214`7i074o//m,m][g 38 sw d 39 trp'; 40 41 if ($new_words =~ /(.*)g$/m){print "$1 ";}else{print "no match ";} 42 43 #sewfbiurev214`7i074o//m,m][ 44 45 my $test = (<> =~ /^sd(.*)/m );if ($test){print "right!,it is $1 ";}else{print "no match ";} 46 47 #sdkkk 48 #right!,it is kkk 49 50 my $what = shift @ARGV;if ($new_words =~ /(.*)($what$)/m){print "right!,it is $1 and $2 ";}else{print "no match ";} 51 52 # perl test.pl g 53 # right!,it is sewfbiurev214`7i074o//m,m][ and g 54 55 $new_words =~ /(.*)g$/m;$new_words =~ /(.*)s$/m;print "$1 "; 56 57 #sewfbiurev214`7i074o//m,m][ 58 59 $new_words =~ /(.*q)?(.*)g$/m;print "$2 "; 60 61 #sewfbiurev214`7i074o//m,m][ 62 63 $new_words =~ /(?:.*q)?(.*)g$/m;print "$1 "; 64 65 #sewfbiurev214`7i074o//m,m][ 66 67 $new_words =~ /(?:.*q)?(2|s)(.*)g$/m;print "$1 and $2 "; 68 69 #s and ewfbiurev214`7i074o//m,m][ 70 71 $new_words =~ /(?:.*q)?(?:2|s)(?<label>.*)g$/m;print "$+{label} "; 72 73 #ewfbiurev214`7i074o//m,m][ 74 75 $new_words =~ /(?:.*q)?(?<label2>(2|s))(?<label>.*)g$/m;print "$+{label} and $+{label2} "; 76 77 #ewfbiurev214`7i074o//m,m][ and s 78 79 my $test2 = 'aavvbbssd'; 80 $test2 =~ /^(?<word1>.)g{word1}(?<word2>.)g{word2}/m;print "$+{word2} and $+{word1} "; 81 82 #v and a 83 84 print "|$`<$&>$'| "; 85 86 #|<aavv>bbssd|