April 25, 201015 yr In a block of text, I'd like to use substitute to swap out every other occurrence of a text string, or every one within the paragraph except the first. Ideally, I'd like to vary by number of occurrences (every [fourth] is unchanged). Are any of these possible? Example Google stock is through the roof. Will Google exceed all expectations? How high do you think Google will go? Go, Google! could become Google stock is through the roof. Will GOOG exceed all expectations? How high do you think GOOG will go? Go, Google!
April 25, 201015 yr To substitute all but the first occurrence of searchString: Let ( [ split = Position ( text ; searchString ; 1 ; 1 ) + Length ( searchString ) ] ; Left ( text ; split ) & Substitute ( Right ( text ; Length ( text ) - split ) ; searchString ; replaceString ) ) To replace (or not) every n-th occurrence, you will need a custom (recursive) function.
April 25, 201015 yr Note that the Substitute() function is case sensitive so SearchString in Comment's calculation must be Google and not google.
Create an account or sign in to comment