string pattern matching using perl regex [closed]

So many things look like a year, especially if unbounded. Since you appear to be looking for the production years of filmed media, we can at least restrict it to the 1900s and 2000s.

$str =~ /\b(?:19|20)[0-9]{2}\b/

If the year in which you are interested will always be in parens, the following will be better:

$str =~ /\((?:19|20)[0-9]{2}\)/

Leave a Comment