I have a string that contains many underscores followed by words ex: "`Field_4_txtbox`" I need to find the last underscore in the string and remove everything following it(including the "\_"), so it would return to me "`Field_4`" but I need this to work for different length ending strings. So I can't just trim a fixed length. 

I know I can do an If statement that checks for certain endings like 

```
if(strstr($key,'chkbox')) {
    $string= rtrim($key, '_chkbox');
}

```

but I would like to do this in one go with a regex pattern, how can I accomplish this?