Hello all,
I have an excel file that contains some data (for e.g. “ABCD(Adv MANAGER) (1234)”) into one column. I want to split data in such a way that one column will contain ABCD(Adv MANAGER) and another column will contain (1234). Please have a look at the below screenshot.
Hi, I am getting “Index was outside the bounds of the array.” error. Instead of hardcoding the values, I want to pull it from the excel column “Description” one by one and then split it on the basis of the second bracket, and then store it in another excel column as specified in the above excel file screenshot.
Create a variable called code, type would be string
For each in DT
1.Assign
code=“”
2.Assign
code=System.Text.RegularExpressions.Regex.Replace(row.Item(“Description”).ToString,“[^0-9]”,“”)
3.Assign
row.Item(“Code”)=“(”+code+“)”
4.Assign
row.Item(“Name”)=System.Text.RegularExpressions.Regex.Replace(row.Item(“Description”).ToString,row.Item(“Code”).ToString,“”)
Above will work only if first half of ur description which is name ,contains only alphabet and second half of description, which is code ,contains only digits.
Hi @sandyk
If possible try to split the string with delimiter as “)(”
Check whether it works or not
Regards
Nived N
Happy Automation
No, It’s not working. Please find the attached excel file. It will be helpful if you help me in solving this issue. String_Split.xlsx (9.5 KB)
No, It will not work as my string will contain one bracket as well as two brackets. Please find the attached excel file.String_Split.xlsx (9.5 KB)
Hi @sandyk
Are u getting any error? Can u provide screenshot of for each loop?
Also,I would like to know how are you reading input excel, will it contain code and name columns ?
Hi, I am not getting any error. BUt result which I am getting are not as expected.
Please have a look on 7th row. Name column contains both code as well as name. and code column for 7th row contains part of name columns data (365 from name column and (1234) from code column.) Also name column contains an extra () bracket at end of every entry.
Hi Yoichi,
It is giving me error for records present in my file. Please have a look on attached file.
String_Split.xlsx (9.5 KB)
Thanks.