<?php

$str = 'This is a number 100 but this isn\'t $100.';
$re = '~\s*(?<!\$)\b\d+~';
$subst = '!';
$result = preg_replace($re, $subst, $str);
echo $result;