cancel
Showing results for 
Search instead for 
Did you mean: 

UDF for Removing Single Space

Former Member
0 Kudos

Hi Experts,

The Source field SourceField1 is mapped to TargetField1 and the length of TargetField1 is of 20 characters only. Lets Suppose If I'm getting one space in the begining then it is causing the problem while generating value in Target.

Lets suppose the value in <SourceField1>00007633574593990389</SourceField1> then the exact value will go in target field, but if there a single space than I may not get the exact value (<SourceField1> 00007633574593990389</SourceField1> then <TargetField1> 0000763357459399038</TargetField1>) . Can anybody provide me UDF wherein I should check if first character is space then it should ignore it and pass correct value.

Regards

Faisal.

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

use standard text function trim() to remove leading (in the beginning empty space) and trailing (ending) space. You dont need UDF for this.

Source field --> trim -> target field

If you want udf still same, create simple udf function pass source value as string parameter (ex str) and return value as string

Example:

public String trimString(str a){

return str.trim();

}

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Fisal,

U no need to use any UDF for this.

As Basker Gopal mentioned you can use the Trim function.

Regard's

Preethi.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

You can use this logic:


                  SourceField1 -> substring: 1..20 -> \
SourceField1 -> substring:0..1 -> equalsS -> ifThenElse -> Target
                     Constant: -> /   SourceField1 -> /

note: value of Constant is a space

Hope this helps,

Mark