How to remove extra value?

Hi All

How can i remove extra value ? Any expression for that?

Thanks in Advance.

@ankur1984 Can you specify what you want to remove from the string

1 Like

Hi @indra i want to remove number , response,1 , 2, 3 then i want to split this value and store in separate variable.


First thing i though if is to use 2 Splits.

First split by environment.newline. This will give you 4 string arrays I’ll call strArr1

For each str in strArr1 (typeargument = string)
If Array.Indexof(strArr1,str) = 0
Then (leave true side blank)
Else YourStringVariable = str.Trim.Remove(2).Trim
End if
Next str

This removes the first 2 characters in the line. Note - this is just a quick & dirty way of doing it. If you have 100+ lines then you should work with a different method which would be to split the line again, remove the first entry in the array, then join the string back together

Assign String
MyText = "1 Apply 20 percent Off for 12 Months Sky Premium Promotion".Trim

Assign String
Pattern = "^(?<Number>\d+)\s*(?<Response>.+)$"

Assign Match
Match = System.Text.RegularExpressions.Regex.Match(MyText, Pattern)

Assign String
Number = Match.Groups("Number")

Assign String
Response = Match.Groups("Response")

Hi @Dave Thanks for reply So, you said First I will Spilt All line then use remove an unwanted word, then again joint the line. it is tricky for me. Can you please explain to me in details?


Sure thing.

Split all line:
I will assume the string you are showing in the message box is saved as a variable called str1. Create a variable (in the variables pane) with a variable type of string array. I’ll call it arrStr1 but you can name it anything you’d like.

Assign arrStr1 = Strings.Split(str1,environment.NewLine)

Now you have an array of strings, where each line in your original string is one of the strings in the array. However, you want to remove the first line since that only contains header information. That can be done as follows:

Assign arrStr1 = ArrStr1.Skip(1).ToArray()

then use remove an unwanted word:
Now for each line that you have, we will turn the string into another array. This will strip out the first portion (the number) and keep the rest.

For each str in arrStr1 (change TypeArgument to String) // Output Index to variable I'll call arrStr1Index
  Assign arrStr1(arrStr1Index) = Strings.Split(str," ",2)(1)  //  This is spitting each line by the space, but it is only splitting into 2 strings. Then the (1) means you only want the second string since index of (0) is the first string.
Next str

Now your array of strings will only contain the values you want!

Here is an example showing what i mean. Note that I dont actually have any input text, so the workflow won’t run as-is. You have to copy over into your workflow for it to work properly. ankur1984.xaml (7.5 KB)

Hi @Dave Thank for your replay i will try it now and let you know. Thanks again


@ankur1984 - I have made an edit. Apparently edits made to each string while iterating through the array of strings doesn’t save to the array itself. I have edited that assign activity so it is working on the array (based on the index in the array) instead. Please see the updated comment and the updated workflow

Hi @Dave,
You saw in message box ( screen sots) I have three option one of value i will get from my work queue so how can I match ? Any suggestions for that? Can I use index expression? I want to just match those value.

Just to be clear, this is separate from your earlier question? The first question said you wanted to remove the excess information and only store the “Apply…” values separately. Now are asking a separate question on how to match a value? Which value are you trying to match? Can you give an example input and example output?

Hi @Dave it is different approach.
My condition is when I get data from work queue. I will get only one data (eg. apply 3 months half …) Now I have compare this data with my data scraping output (you see in screen shot).
How can I do? TRUE OR FALSE

I will assume you saved data scraping output as a string called str1. I will assume your queueitem variable is called qitem and has a field called “data” that is a string.

The following expression will output a true or false: str1.contains(qitem.SpecificContent("data").ToString)

Thanks @Dave yes ur right. I will try tomorrow and let you know. Thank again It would be a great help.

Hi, @Dave Is it possible without qitem how i can use this same expression? because right now i don’t have a (UiPath.core.QueueItem) type variable. (for testing)


Hi, @Dave Is it possible without qitem how i can use this same expression?

Yes, just replace that portion with whatever format the data is being stored in. You mentioned “data from work queue” which I assumed was a queue item variable.

@Dave Check this its said you not declare qitem variable.

qitem was just what I was calling the queueitem variable in my example. You said you weren’t using a queueitem variable. What type of variable are you using? You need to replace qitem.SpecificContent("In_Promotions_Value").ToString with the variable type (and variable names) that you are using instead

i am using sysytem.collection.Generic .type variable.

I would recommend not using generic variables (and other anonymous types) wherever possible, but replace qitem.SpecificContent("In_Promotions_Value").ToString with YourVariableName.ToString and it should work instead. YourVariableName should be whatever you named your variable