I have the data below which I am trying to parse out the tittle with each of the following RegEx,   Some Entries have a (Year) or other do not. same with the database number.  is seem to get different results. https://regex101.com/r/lS9fQ2/2(.*) every character until a _( (space open parenthesis) or -tt (dash tt) is found    (.*)\s\(|\-tt    (.*)(\s\(|\-tt)DataMinions 2-tt2293640Minions 2 (2012)-tt2293640Chappie (2015)Peanuts Movie, The (2015)Batman Bad Blood (2016)-tt4870838Ant-Man (2015)-tt047897022 Jump Street (2014)-tt2294449Bean (1997)Bedtime Stories (2008)Begin Again (2013)Beneath the Planet of the Apes (1970)Best of Me, The (2014)Beverly Hills Cop (1984)Beverly Hills Cop II (1987)Beverly Hills Cop III (1994)Big Hero 6 (2014)Big Short, The-tt1596363Birdman (2014)Biutiful (2010)Black Book (2006)Blackhat (2015)-tt2717822Black Hawk Down (2001)Black Mass (2015)-tt1355683Black Swan (2010)Blade Runner (1982)-tt0083658Blended (2014)Blood Ties (2013)Body Of Lies (2008)Bolt (2008)Born To Be Wild (2011)Does anyone have a clue as to what I am missing?
Simple Regex match not working
regular expression
Using the perl regexp engine (you did not specify what you are using), this can be achieved with:perl -pe 's/^(.*?)( \(|-tt).*/\1/' < indata.txtThe trick is to make the first .* match non-greedy with .*?, or it will consume the year part for any line that has both a year and the -tt id.