[ create a new paste ] login | about

Link: http://codepad.org/WCXYLbe4    [ raw code | output | fork ]

kinopiko - Perl, pasted on Dec 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
my $lines = <<EOF;
"  AString "   // leading and trailing spaces together allowed
"AString "     // trailing spaces allowed
"  AString"    // leading spaces allowed
"newString03"  // numeric chars allowed
"!stringBIG?"  // non-alphanumeric chars allowed
"R"            // Single UC is a match

"A String" // not a match because it contains an embedded space
"a_string" // not a match because there are no UC chars
EOF

for my $line (split /\n/, $lines) {
$line =~ s://.*$::;
print $line;
if ($line =~ /"(?![^"\s]+\s+[^"\s]+")[^"]*[A-Z][^"]*"/) {
   print "matches\n";
} else {
   print "does not match.\n";
}
}


Output:
1
2
3
4
5
6
7
8
9
"  AString "   matches
"AString "     matches
"  AString"    matches
"newString03"  matches
"!stringBIG?"  matches
"R"            matches
does not match.
"A String" does not match.
"a_string" does not match.


Create a new paste based on this one


Comments: