107

Regular Expressions
Pattern Matching by Example

  • Here are several examples which demonstrate typical usage patterns for regular expression matching

  • Skip over comment lines
      while ( $line = <STDIN> ) {
      	next if ( $line =~ /^#/ );
      	...
      }
      
  • End a loop
      if ( $line =~ /[aeiou]/i ) {
      	# Vowel
      } else {
      	# Consonant
      }
      
  • Notice the i at the end of the expression?
    There are several options you can use with / ... /...