Assume we have a php array $row_mid, which contains strings like 'reaction_l0', 'reaction_l1', 'reaction_r0', 'reaction_r1' (in each case the number goes from 0 to 4. These strings are enclosed by
<div>
$i = 0;
while ($i < count ($row_mid)){
$row_mid [$i] = preg_replace ("~^reaction_.[0-9]$~", "", $row_mid [$i]);
$i++;
}
<div>reaction_r1</div>
reaction_r1
Get rid of the anchors, because they only allow the regexp to match the entire string, not when it's enclosed in tags.
$row_mid [$i] = preg_replace ("~reaction_.[0-9]~", "", $row_mid [$i]);