To remove unnecessary characters in string

One Star

To remove unnecessary characters in string

Hi,
I just wonder how do I wants to removed certain character or word in string.
For example, there is string with data "good-morning". Then i wants to remove "-morning" and then the data will become as "good" only.
Plz help me Smiley Sad

Regards,
Kal
Moderator

Re: To remove unnecessary characters in string

Hi,
tFileInputPositionalComponent and tFileInputRegex component can meet your needs.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: To remove unnecessary characters in string

Or in a tMap you could use column_name.replace("-morning","")
Moderator

Re: To remove unnecessary characters in string

Hi, ae_kel29
I just wonder how do I wants to removed certain character or word in string.

If your requirement is just the example you set, the way @janhess provided is very good for you.
But if your real work have a lot of strings, it suggestion that use column_name.substring(int startIndex, int endIndex) in tMap.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: To remove unnecessary characters in string

column_name.substring(int startIndex, int endIndex) in tMap.

This assumes the string to replace is in a fixed position.
Moderator

Re: To remove unnecessary characters in string

Hi,
Yep, it depends on the replaced strings.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: To remove unnecessary characters in string

Hi There
How do i remove stranges caracteres li "" on tmap when passing a string??
Moderator

Re: To remove unnecessary characters in string

Hi eliton,
For you requirement, you can use method "ReplaceAll(string s1, string s2)" in tMap component expression.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: To remove unnecessary characters in string

replaceAll function throws null pointer expression when no matching string found.

Thirteen Stars

Re: To remove unnecessary characters in string

@ContactNitesh89,can you try the below one.

 

column_name==null ||"".equals(column_name) ? column_name : column_name.replaceAll("-morning","")

Manohar B
Thirteen Stars

Re: To remove unnecessary characters in string

@ContactNitesh89,still do you have issue?

Manohar B