How to get part of the string

Hi All,

I have string "“Load Disp ENS - WI - La Crosse WI” this i will get as queue item
this value i have to select from drop down list. In drop down i will not get exact value.
I will get till “Load Disp ENS - WI” how to get part of the string.

i used split method based on delimiter Like below.

“strGroup.Split({”-“},StringSplitOptions.RemoveEmptyEntries)” with this iam getting
“Load Disp ENS” string but i want like this “Load Disp ENS - WI”
how to do that. this value is dynamic.
Can some one help me

first split the string with -
VariableA =split(StringVariable,“-”)(0)
VariableB=split(StringVariable,“-”)(1)

finalString=VariableA +“-”+VariableB
it will return Load Disp ENS - WI

hope it will work

Hi,

This will not solve value is dynamic in that case how to split? I iwll get some times in string only one hyphen some time no hyphen only spaces
image

As you mentioned you need to select from a drop down list.

The optimum solution will be to just see how many max characters are present for each option in the drop down list and then take only those many characters from the queue item.

As you mentioned once list item as “Load Disp ENS - WI”, this signifies 18 characters.

So just extract first 18 characters from the queue item.

One of the many way is to use Left function.

Left(QueueItem.toString,18)

Just in case you need below is a useful post related to the string manipulation.

1 Like

can you show me the different multiple strings that you think is possible. I mean possible scenarios what kind of strings you will receive?

I gave solution only to the above string that you have shared.

image

you have to select only first three parts right?
for example consumer-collections-service-cris → consumer-collections-service

Its dynamic some times 2 parts some times 3 based on data we get from API that data adding to queue in drop down values and queue item value should match

dropdown value is not dynamic queue value is dynamic

Queue value will be like image
But in drop down “Load Disp ENS - WI”

You won’t be able to split the string correctly since you don’t know where to cut or if you should cut the string at all.

Could you test if you can capture the dropdown list using the Get Attribute activity with the Attribute set to “items”? If you can obtain the list, here’s an idea:

  1. Filter out all list items that have a partial match of strGroup, e.g. strGroup.StartsWith(item)
  2. If there’s only one match, you have found your workgroup. If not, go to 3.
  3. Sort the matched items by string length. The item with the longest length is your workgroup.

You should try Regular Expressions. They can help match one or more different kinds of string patterns (in this case with hyphen, and without hyphen).

https://regexr.com/ is a good place to start learning basics of Regular Expressions