while ( <> ) { s{ -\|-.*? # After the -|- thingy ( \d+(?:-\d+)? # A number, maybe two ) } { print $1 . "\n" }egx ; }