I have text file and I have around 100 strings separated by , . I need to select a particular string and need to remove all strings before that particular string

I have text file and I have around 100 strings separated by , . I need to select a particular string and need to remove all strings before that particular string

Any suggestions would be helpful.

Thanks
Nawaz.

Hi @Mohammed_Nawazuddin,

Have you tried splitting it according to the series you chose?

For example value= 123,234,232,111,222,333
if you want to choose a 232 string and remove the previous one.
value.split(",232"c)(1)

then you can get a list from the rest by splitting it according to the comma.

Regards,
MY

Hey @Mohammed_Nawazuddin

If your desired text pattern is unique OR constant you can β€˜collect it’ using Regex with one activity. Take a look here.
If you provide a Sample, expected Output, and tell us what is consistent / provide information on the Pattern.
You can also achieve this using String Manipulation.

Take a look here at these two posts:

Cheers

Steve

Hi,

Thanks for quick reply.

The β€˜232’ value is declared in the variable and I need to remove all the strings begore β€˜232’.

Thanks,
Nawaz.

you can first find the index of that particular string and simple use remove function

string = string.remove(0,"index of particular string ")

I am passing the above same syntax but getting error as

attach your project xaml i will check

@Mohammed_Nawazuddin The syntax is wrong here. Remove method always accepts two arguments

  • Start Index (Integer) - it define the position to begin deleting characters
  • Count(Integer) - The number of characters to delete

In your screenshot dt_Last should be an integer but you are trying to convert that to string . So it is showing that error. remove .ToString and make sure that variable is an integer. Below doc for ref

1 Like

@Mohammed_Nawazuddin
Try this Expression-

Strings.Split(Test_String, ",232").Last

The above expression worked buts it is skipping β€˜232’ value and taking 111 as first string I need 232 value as first string.

Thanks,
Nawaz.

Hi @Mohammed_Nawazuddin ,

Could you try the Below :
image

Output we get :
image

The Expression used to get the Modified value :

String.Join(",",Split(textStr,",").SkipWhile(Function(x)Not(x.ToString.ToLower.Equals(chosenString.ToLower))))

Let us know if you are still facing difficulties.

Hi @supermanPunch ,

It worked. Thanks very much

1 Like

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