Question: I'm stuck writing a preg\_match

I have a string:

```
XPMG_ar121023.txt

```

and need to extract the 2 letters between `XPMG_` and the first digit - be it a 0-9

```
$str = 'XPMG_ar121023.txt';
preg_match('/('XPMG_')|[0-9\,]))/', $str, $match);
print_r($match);

```

Maybe this isn't the best option: My characters will always be

Answer: 
You can just do 

```
$str = "XPMG_ar121023.txt" ;
preg_match('/_([a-z]+)/i', $str, $match);
var_dump($match[1]);

```

Output

```
string 'ar' (length=2)

```
This is too simple for a regular expression. Just `$match = substr($str,5,3)` would get what you're asking for.