需要PHP自定义功能代码WP All Import - Wordpress

I had a CSV with products to be imported to Woocommerce Via WP All Import Plugin.

The CSV had extra category text that needed to be removed before the hyphen ( - )

So the WP All Import team told me to use the following code in the function editor:

function my_cat( $subcat )
{
$subcat = explode("-", $subcat);

$new_sub = array_key_exists(1, $subcat)?$subcat[1] : $subcat[0];

return trim($new_sub);
}

Then call it with the snippet below:

[my_cat({prodlinelangname[1]})]

This worked fine but the problem now is that i have a new CSV that needs to remove text both before and after hyphens.

For example;

TEXT1 - TEXT2 - TEXT3

I need to remove everything from the CSV field except TEXT2.

What code can i use?

Cheers, Victor