#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    7
    Rep Power
    0

    Question Replacing a char


    I am trying t o replace just one char in a string. However, when I try to use the Replace function in the below context (newTimeStamp being 20-something characters long):

    newTimeStamp = Replace(newTimeStamp, "5", " ",4,1)

    It truncates my string by 8 characters!

    For example, if newTimeStamp was ="123456789" then the result would be "4 6789"

    Does anyone know why it is doing is this? And, just as importantly, how to get it not to?

    I know I could Mid the first 3 digits and splice the two strings together, but I'd assume that there is a way to just replace the culprit char and save the rest of the string!

    Help!
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    792
    What is happening is that when you tell it a start position, it returns a substring from this position on.
    Unfortunately I do not know of a way around this except not to specify a start position.

IMN logo majestic logo threadwatch logo seochat tools logo