Replaces text found in the search string with the text provided as a replacement text.

 

Useful to replace colons with commas, as an example, in the correlation matrix so you can use the GetField function.

 

Syntax:

newString = ReplaceString( inputString, stringToReplace, stringToReplaceWith )

 

Parameter:

Description:

inputString

String where replacement will be found and replaced.

stringToReplace

Target text to find in the search string.

stringToReplaceWith

Replacement text that will be inserted into the place where the target string is removed.

 

Example:  Replace Word

'  Word Replacement Example

VARIABLES: sNewText Type: String

 
'  Remove Any Text That looks like: 'Hello' and append 'World'
sNewText = ReplaceString( "Hello World", "Hello", "Goobye" )

 
PRINT "ReplaceString = ", sNewText

 

Results:

ReplaceString =  Goobye World

Example:  Replace Colons with Commas

'  Correlation Matrix Description Example

VARIABLES: sNewTextNum TYPE: STRING
 
sNewTextNum = ReplaceString( "123:456:789", ":", "," )
 
PRINT "ReplaceString = ", sNewTextNum

 

Results:

ReplaceString =  123,456,789

Example:  Remove Commas in Numbers

'  Remove Commas from a number with comma seperations
VARIABLES: sNewTextNum TYPE: STRING

 
sNewTextNum = ReplaceString( "123:456:789", ":", "" )

 
PRINT "ReplaceString = ", sNewTextNum

 

Results:

ReplaceString =  123456789

 

Links:

AsString, FormatString, RemoveNonDigits

See Also:

Data Groups and Types

 


Edit Time: 9/25/2017 09:09:54 AM


Topic ID#: 498

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software