in reply to regexp: extracting info

You almost have it. Two things are wrong:

  1. You need to put $number into list context to retrieve $1
  2. Read up the bit on character classes again in perlre, they allow you to match a range of single characters, you still need to quantify them if you want to match more than once. [ee] and [e] are equivalent and will both match a single character "e".

this will work:

($number) = $str =~ /abc\sdddd\s+(?:ee\s+)?(\d+)/;

As for your question about the two extended operators, they influence capturing of an expression in brackets. perlre really explains it the best way I know, though you may want to take a look at Mastering Regular Expressions which is a very worthwhile book to read when learning regular expressions.

Update:Removed "gs" as they're not necessary (thanks to prasadbabu for pointing that out)


Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it. -- Brian W. Kernighan