YUANya

导航

 
 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\Z/){print "$1\n";}else{print "no match\n";}
14 
15 #   kkk
16 
17 if (/^n(.*)/m){print "$1\n";}else{print "no match\n";}
18 
19 #inq   kdownc
20 
21 if (/(.*\bn.n\b.*)/){print "$1\n";}else{print "no match\n";}
22 
23 #no match
24 
25 if (/.*(\Bn.n\B).*/){print "$& and $1\n";}else{print "no match\n";}
26 
27 #aninp and nin
28 
29 if (/\w*(i)\w*/){print "$& and $1 and $` and $'\n";}else{print "no match\n";}
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\n";}else{print "no match\n";}
42 
43 #sewfbiurev214`7i074o//m,m]\[
44 
45 my $test = (<> =~ /^sd(.*)/m );if ($test){print "right!,it is $1\n";}else{print "no match\n";}
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\n";}else{print "no match\n";}
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\n";
56 
57 #sewfbiurev214`7i074o//m,m]\[
58 
59 $new_words =~ /(.*q)?(.*)g$/m;print "$2\n";
60 
61 #sewfbiurev214`7i074o//m,m]\[
62 
63 $new_words =~ /(?:.*q)?(.*)g$/m;print "$1\n";
64 
65 #sewfbiurev214`7i074o//m,m]\[
66 
67 $new_words =~ /(?:.*q)?(2|s)(.*)g$/m;print "$1 and $2\n";
68 
69 #s and ewfbiurev214`7i074o//m,m]\[
70 
71 $new_words =~ /(?:.*q)?(?:2|s)(?<label>.*)g$/m;print "$+{label}\n";
72 
73 #ewfbiurev214`7i074o//m,m]\[
74 
75 $new_words =~ /(?:.*q)?(?<label2>(2|s))(?<label>.*)g$/m;print "$+{label} and $+{label2}\n";
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}\n";
81 
82 #v and a
83 
84 print "|$`<$&>$'|\n";
85 
86 #|<aavv>bbssd|

 

posted on 2019-06-23 19:34  YUANya  阅读(460)  评论(0编辑  收藏  举报