Check for leading alpha character, rest alphanumeric : Pattern matching « Regular Expression « Perl






Check for leading alpha character, rest alphanumeric

    


#!/usr/bin/perl -w

foreach $patt (@ARGV) {
    # Check for leading alpha character, rest alphanumeric.
    if ($patt =~ /^[a-zA-Z]+[_0-9a-zA-Z]*$/) {
        print "\tLeading alpha, then alphanumeric in \"$patt\".\n";
    }
}

   
    
    
    
  








Related examples in the same category

1.Pattern Matching Operators
2.Pattern Modifiers
3.Pattern Tester
4.Pattern anchors in Perl.
5.Pattern array
6.Pattern match
7.Pattern-Matching Operators(The syntax used to perform a pattern match on a string)
8.Pattern-matching options.
9.Patterns containing + always try to match as many characters as possible.
10.Using variables containing matched subpatterns.
11.Regular Expression Patterns
12.Regular expression character patterns
13.Regular expression metacharacters
14.Regular expression modifiers
15.Regular expression pattern quantifiers
16.Regular expression: start a string with period
17.Reversing subpatterns
18.Repeating patterns
19.Check for 'a'
20.Check for 4-8 a's
21.Check for a or b
22.Check for and remove a trailing backslash character
23.Check for no 'a'
24.Check for white space
25.A program that illustrates the use of the matching operator.
26./d.f/ matches d, followed by any non-newline character, followed by f
27./de{1,3}f/ matches d, followed by one, two, or three occurrences of e, followed by f.
28.Print line unless it matches E
29.Count the match times