use strict; use warnings; my $rxTitle = qr {(?x) # Use extended syntax (?<=-\s) # If preceded by hyphen & space ( # Open capture [^(-]+ # One or more non- opening parentheses # or hyphens (?: # Non-capture group for quantifier [^)]+ # One or more non- closing parentheses \) # Followed by a closing parenthesis )? # Quantify, zero or one of ) # Close capture (?=\s?) # If followed by optional space and # closing title tag }; while ( ) { my ( $text ) = m{$rxTitle}; print qq{$text\n}; } __END__ GRP -134 - Grinding And Cutting Solution (ACME PR50 - Water Type) GRP-123-1 - Grinding And Cutting Solution (Quakeroat 2780 UTC - Synthetic Type) GRP-124 - Alkaline Rust Remover Solution GRP-124-1 - Alkaline Rust Remover Solution (Ardvark 185 - Rust Remover) GRP-124-2 - Alkaline Rust Remover Solution (Ardvark 185L - Rust Remover) GRP-124-3 - Alkaline Rust Remover Solution (Bee-Dee J84AL - Rust Remover) GRP-124-4 - Alkaline Rust Remover Solution (Mag HD2-202 - Rust Remover) GRP-124-5 - Alkaline Rust Remover Solution (Turk 4181L - Rust Remover) GRP-124-6 - Alkaline Rust Remover Solution (Turk 4181 - Rust Remover) GRP-124-7 - Alkaline Rust Remover Solution (Bee-Dee J84A - Rust Remover) GRP-124-8 - Alkaline Rust Remover Solution (Cadilac HTP-1150 - Rust Remover) GRP-124-9 - Alkaline Rust Remover Solution (Cadilac HTP-1150L - Rust Remover) GRP-124-10 - Alkaline Rust Remover (Titanium Long Soak)