How to Split a String

thank you all

Suppose ABC variable is stored with value “This is not game”
String ABC=“This is not a game”

There is a Split function available in String Class.
It operates two parameter
1.String name on which the operation should be performed
2.Delimiter for the string

It returns String of array, so use appropriate code.

String array_of_string=Split(ABC,“not”)
OR
String array_of_string=String.Split(ABC,“not”) --------// To be specific

2 Likes

Split(str.ToString,“-”)

3 Likes

Hi,

I am trying to split a string 14;687$ into 14 and 687 for further processing. Could someone tell me how this should be done? Thanks!

Hi @merlinazzz ,

string->stramount->14;687$

stramount.split(“;“c)(0)—>14
stramount.split(”;“c)(1).replace(”$”,“”)---->687

Regards,
Arivu

7 Likes

great, thanks a lot!

please I want to split from variable like this the name of the file is Rabeaalhaj _1234_basic.pdf here I want to put the name in one variable and the ID in another variable and the word basic in variable also so please how can I split them

Hi @rabea_alhaj,

Refer

Regards,
Arivu

4 Likes

“Please take note of your order reference: 156”
I want to separate 156 from the above expression and want to write in an excel. I just separated using a split string but when written in an excel it only writes “System.String” instead of 156.

Hi @VASUDEVGUTTIKONDA you can use activity “Matches”
with input: your string (str)
Pattern: “(?<=reference: ).*(?=”“)”
result: your string

3 Likes

i do read from the excel sheet with different values and finally, I will get this expression “Please take note of your order reference: ???”. i have used split string activity to split like this “Please take note of your order reference:” “???” and finally i want to write this “???” into the excel while writing in excel it displays “system.string” instead of “???” this value.

Hi @VASUDEVGUTTIKONDA,

You can get in 3 ways.

  1. Replace string

StrValue=StrValue.Replace(" Please take note of your order reference:","")

2.using regex you can get the value.
If suppose your ??? Value is number.
StrValue=System.Text.RegularExpressions.Regex.Match(StrValue, "[0-9]").Value

  1. Using substring also you can get the value.

StrValue=StrValue.SubString(StrValue.Length-3)

Regards,
Arivu

3 Likes

Hi Team,

I have a requirement where, uipath will read the Excel File and based on that will enter the data in a web-based banking application.

On the application side, there is table of products which I am not able to scrap because it is “table inside table”.

ProductList

Hence I am using Get Full Text Activity to take the records from the grid and it is coming like this:


0100601006 - Current Accounts One Tarrif Premium - Retail: PremiumKES

O
0200602006 - Current Accounts One Tarrif Premium - Retail: PremiumUSD

O
0300603006 - Current Accounts One Tarrif Premium - Retail: PremiumEUR

O
0400604006 - Current Accounts One Tarrif Premium - Retail: PremiumGBP

In the excel file only five digits will be mentioned e.g. ‘01006’.

Need to split the first five digits and based on entry in excel need uipath to select the product.

Please help.

Thanks

Hi @thepathbreaker,

strValue="0100601006 - Current Accounts One Tarrif Premium - Retail: PremiumKES"

ProductId=strValue.SubString(0,5)
Desc=strValue.Substring(5,strValue.Length-8)
Currency=strValue.Substring(strValue.Length-3)

Regards,
Arivu

4 Likes

Thanks for the quick reply @arivu96

As you can see ‘✓’ and ‘O’ are also coming while Getting Full Text. How can we get rid of that. So that my string will come like this:

0100601006 - Current Accounts One Tarrif Premium - Retail: PremiumKES
0200602006 - Current Accounts One Tarrif Premium - Retail: PremiumUSD
0300603006 - Current Accounts One Tarrif Premium - Retail: PremiumEUR
0400604006 - Current Accounts One Tarrif Premium - Retail: PremiumGBP

Hi @thepathbreaker,

So you will get the string from the string you can split using Environment.NewLine to split the each row.
out put seem like ‘✓’ and ‘O’ is coming in superate line so if its come skip.

Regards,
Arivu

Hi all,
I have a similar Problems but could not find a solution so far.
I have a text “The Number is 123456. Thanks” but I just need the expression “123456”.
Of course, the numbers are unique so I can not just search for it but the text is always the same.

Hi @tomatosoup,
input->string
input=“The Number is 123456. Thanks”

input = Regex.Replace(input, "[^0-9]+", string.Empty)

Regards,
Arivu

3 Likes

Sorry; I can not follow :(.

I have done the following:

  • Creating two String Variables: “Text Request” and “AccessNumer”
  • “Get visible text”-activity
    → getting the text
  • “Assign”-activity
    → AccessNumber=Split(Split(TextRequest,“Document”,10)(1)," ")(1).Trim

Hi,
How to use " as a delimiter in String Split option

1 Like