How to remove text in a string

I am unsure how to use the replace activity to remove text from a string - can anyone explain simply how to configure this?

Hi @E.T.S ,

Could you provide us with the Input Data and the Expected Output for that data? This is asked so that we can analyse and provide the appropriate suggestions for your case.

Hi,

My string looks like this: abcn/a
And I want it to look like this: abc

So the n/a is removed

I can’t use the trim method as there a lot of ‘n/a’ in the string

I am confused what these options do:
image

@E.T.S ,

I believe you are using the Replace activity, we could try with the below configuration :

Here we are assuming that n/a is at the end of the string always. If it is not at the end always, then you could remove the $ symbol at the End of the Pattern and check.

Hi @E.T.S

Use this in Assign activity

originalString=abcn/a
modifiedString= originalString.Replace("n/a", "")

Hope it helps

1 Like

Please could you show me these configurations in the ‘configure regular expression’ setting

That worked thanks! Is there a way I can replace multiple characters in the original string in the same line of code or would that require multiple assigns

You can remove multiple n/a in one string.

If you have another you need to have another assign activity with same syntax.

Regards

1 Like

@E.T.S ,

The Configuration is done like below, Although I did directly assigned it from the Properties Panel.

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.