Hi,
Thought of sharing a solution I have built to replace a sub-string in the string (similar to EReplace), but it is not a function.
(it will work only for the single occurance - I will post the solution for multiple occurance as well)
Input: I have ID and DESCRIPTION fields and Description has invalid string ' ' I want to replace it with ' ' (space)
1. To replace the single occurance
Transformer Stage:
Stage Variables:
VariableName:svStartPos
Initial Value: 0
SQLType: Integer
Derivation: Index(DSLink3.DESCRIPTION, " ", 1)
VariableName: svTotalLength
Initial Value: 0
SQLType: Integer
Derivation: Len(DSLink3.DESCRIPTION)
VariableName: svDescription
SQLType: VarChar (length should be same as your input column)
Derivation:
If svStartPos >0 Then
DSLink3.DESCRIPTION[1, svStartPos - 1] : ' ' : DSLink3.DESCRIPTION[svStartPos+6, svTotalLength - (svStartPos + 6 -1)]
Else
DSLink3.DESCRIPTION
---6 is length of my substring I want to repace
Output:
Map the svDescription to output
Replace String without Using EReplace Function
Moderators: chulett, rschirm, roy
Remove invalid characters or replace string with another - when it has multiple occurrences...
Input: DSLink3.Description
Invalid String:  
I want to replace it with Space: ' '
--Stage Variables:
VariableName:svStartPos
Initial Value: 0
SQLType: Integer
Derivation: Index(DSLink3.DESCRIPTION, " ", 1)
VariableName: svTotalLength
Initial Value: 0
SQLType: Integer
Derivation: Len(DSLink3.DESCRIPTION)
VariableName: svDescription
SQLType: VarChar (length should be same as your input column)
Derivation:
if svCount=0 then
DSLink3.DESCRIPTION
Else svDescription
VariableName-svCount
Initial Value: 0
SQLType: Integer
Derivation: count(DSLink3.DESCRIPTION,' ')
--Loop Condition
Loop While: @ITERATION <=svCount + 1
Loop Variable:
lpDescription:
If lpCount=0 then DSLink3.DESCRIPTION Else
lpDescription[1, lpStartPos - 1] : ' ' : lpDescription[lpStartPos+6, svTotalLength - (lpStartPos + 6 -1)]
lpStartPos: Index(lpDescription, " ", 1)
lpCount: If lpCount=0 then svCount Else lpCount - 1
--Output:
Constraint: lpCount=0
Map the lpDescription to output
Input: DSLink3.Description
Invalid String:  
I want to replace it with Space: ' '
--Stage Variables:
VariableName:svStartPos
Initial Value: 0
SQLType: Integer
Derivation: Index(DSLink3.DESCRIPTION, " ", 1)
VariableName: svTotalLength
Initial Value: 0
SQLType: Integer
Derivation: Len(DSLink3.DESCRIPTION)
VariableName: svDescription
SQLType: VarChar (length should be same as your input column)
Derivation:
if svCount=0 then
DSLink3.DESCRIPTION
Else svDescription
VariableName-svCount
Initial Value: 0
SQLType: Integer
Derivation: count(DSLink3.DESCRIPTION,' ')
--Loop Condition
Loop While: @ITERATION <=svCount + 1
Loop Variable:
lpDescription:
If lpCount=0 then DSLink3.DESCRIPTION Else
lpDescription[1, lpStartPos - 1] : ' ' : lpDescription[lpStartPos+6, svTotalLength - (lpStartPos + 6 -1)]
lpStartPos: Index(lpDescription, " ", 1)
lpCount: If lpCount=0 then svCount Else lpCount - 1
--Output:
Constraint: lpCount=0
Map the lpDescription to output