Drupal views integration ContactID inserts commas into number
When you pull the contact ID as a field in the view (even before you replace it), to what is the thousands marker field set?  I believe the default setting is comma (see http://screencast.com/t/8tiEiqVOBG ) - you might check that and change it to "none" if that is the case, to see if that makes a difference.