These are examples of my strings:
My title - K21
Some title - G-21
Title something - M-02
I need to strip the code and the hyphen so I get clear title.
My title
Some title
Title something
This is the code I came up so far, but it gives me G-21 as result, and I need the opposite, I need a result of regular expression.
$string = 'Some title - G-21';
$pattern = '/.+? (?=–)/i'; // this is ok, – is for '-'
echo preg_replace($pattern, '', $string);