I am using Twig templating for PHP with plugin (https://github.com/jasny/twig-extensions) that includes functions like preg_replace.
I have the follow strings:
Coverking_CSC_Neosupreme_1Row-F-150_Series-01-MASS
Coverking_CSC_Neosupreme_1Row-F-150_Series-01-ANYTHING
Coverking_CSC_Neosupreme_1Row-F-150_Series-01
I want to replace the last occurrence of -XX or -XXANYTHING with empty string.
So the results of replacements for all strings above should be
Coverking_CSC_Neosupreme_1Row-F-150_Series
I managed to look online and found the following regular expression to remove the last occurrence of -XX
str|preg_replace("/\-[0-9]{2}(?!.*\-[0-9]{2})/","")
How can I modify the above regex to give me the desired results?
Thank you