I have variables as follow in PHP

```
steve_s_baue
marine_camp_se_bell
mike_wane

```

I want to only keep the first and last part:

```
steve_baue
marine_bell
mike_wane

```

I tried to use `trim` but got stuck.

**EDIT: Here is what I tried to far**

```
$row = $pre_results[$i];    
$name = $row -> name;
$text = preg_replace('~[^\pL\d]+~u', '_', $name);
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
$text = preg_replace('~[^-\w]+~', '', $text);
$text = trim($text, '_');
$text = preg_replace('~-+~', '_', $text);
$text = strtolower($text);              

```

Any suggestions?