Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello folks,
I have a case where my string value is something like this whose length is 9.
12345-6789
In this case I have to keep the same value as it is.
But when I have the string value 12-23 or 8765-768 I have to remove the hypen(string length is less than 9)
I want to format like above. Can someone please help as part of this.
I have the formula like this.
StringHandling.LEN(Post_Formatting.BILLED_COMPANY_ZIP)== 9
? Post_Formatting.BILLED_COMPANY_ZIP : Post_Formatting.BILLED_COMPANY_ZIP.replaceAll("-", "")
But it is not working.
Regards,
Deepak
Hi Kiran,
Since in your condition it does not affect the string values more than 9, I did not use it,
Instead i have just tweaked my formula as below and it worked.
StringHandling.LEN(LP_Z_SERVICE_ADDRESS.ZIP)== 10
? LP_Z_SERVICE_ADDRESS.ZIP : LP_Z_SERVICE_ADDRESS.ZIP.replaceAll("-", "")
But thanks for your kind response on this.
Regards,
Deepak
12345-6789 is not a String of length 9, it is of length 10. Your code says....
"When the String is length 9, leave it alone. When it is not length 9 (either less than 9 or greater than 9), remove all '-' characters"
I don't think that is what you want is it?
Can you tell us what you want with examples? Make sure they are accurate examples.
I think I got the mistake what I am instructing Talend through below code.
StringHandling.LEN(Post_Formatting.BILLED_COMPANY_ZIP)== 9
? Post_Formatting.BILLED_COMPANY_ZIP : Post_Formatting.BILLED_COMPANY_ZIP.replaceAll("-", "")
I will correct this as
StringHandling.LEN(Post_Formatting.BILLED_COMPANY_ZIP)== 10
? Post_Formatting.BILLED_COMPANY_ZIP : Post_Formatting.BILLED_COMPANY_ZIP.replaceAll("-", "")
Requirement is:
When The string has 9 digit value and in between it has hypen(so it is 10 length as you said) I want keep this as it is, else remove the hypen.
Thanks for the reply
hi,
please find the attachment and solution. if its correct give as resolved and kudos.
StringHandling.LEN(row4.hypen_data<9?StringHandling.EREPLACE(row4.hypen_data,"-",""):row4.hypen_data
Thanks
Venkata Kiran
That doesn't cater for over 10 characters? Is that possible? What would be the rule if that did happen?
There are only 2 cases,
One if the string has 9 digits and in between one Hypen then keep as it is.
If it is lesser than 9 digits then, we have to remove hypen.
The above is the rule.
Your update should work then. Have you tried it?
is my solution correct ?
Hi Kiran,
Since in your condition it does not affect the string values more than 9, I did not use it,
Instead i have just tweaked my formula as below and it worked.
StringHandling.LEN(LP_Z_SERVICE_ADDRESS.ZIP)== 10
? LP_Z_SERVICE_ADDRESS.ZIP : LP_Z_SERVICE_ADDRESS.ZIP.replaceAll("-", "")
But thanks for your kind response on this.
Regards,
Deepak