User:OverKill

<?php
$test = '[[File:Mana_R.png]]g';
$char = 'g';
$pattern = '/(?<!.n)'.$char.'/';
preg_match_all($pattern, $test, $matches);
print_r($matches);
?>

This is perfect because it won't match the g with a n preceeding it.

Tomorrow I will have it finished hopefully.