You need to use a lookahead assertion like below. Below positive lookahead asserts that the match must be followed by the string - Season 1
.*(?=- Season 1)
Example:
> "The Big Bang Theory - Season 1".match(/.*(?=- Season 1)/)
=> #<MatchData "The Big Bang Theory ">
> "The Big Bang Theory - Season 1".match(/.*(?= - Season 1)/)
=> #<MatchData "The Big Bang Theory">
solved regular expression to extract a string with ruby regex [closed]