craigmartin
(craig.martin)
February 15, 2024, 11:16pm
1
I’m trying to split the two text delimited by a comma. My problem was when making an output of the arrText(1).ToString it include the text of the next row. How to remove that?
This is the sample text.
170766123,itemA66373216
188059977,itemA01502409
169498025,itemA48202024
147855226,itemA11666073
ppr
(Peter Preuss)
February 15, 2024, 11:27pm
2
we can treat is like CSV Data and using comma as delimiter char
have a look at:
The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...
And
The UiPath Documentation Portal - the home of all our valuable information. Find here everything you need to guide you in your automation journey in the UiPath ecosystem, from complex installation guides to quick tutorials, to practical business...
And Regex
This CheatSheet introduces the basic use of regex functions. With further examples also special cases are presented.
Introduction
From the namespace System.Text.RegularExpressions following methods are offered:
Regex.Match
Regex.Matches
Regex.isMatch
Regex.Replace
Regex.Split
A simple usage for example would look like this:
[grafik]
Recommendation:
add System.Text.RegularExpressions to the imports:
[grafik]
it allows to use the shortened statement, as the namespace part can be ommited…
Yoichi
(Yoichi)
February 15, 2024, 11:31pm
3
Hi,
In this case, it may be better to split by linebreak in advance, as the following.
Sample
Sample20240216-1.zip (2.7 KB)
Or try parse it as CSV using ReadCSV or GenerateDataTable etc as @ppr mentioned
Regards,
postwick
(Paul Ostwick)
February 16, 2024, 12:31am
4
This is CSV text. Use the Generate Data Table activity.
sandhyj3
(Sandhyj3)
February 17, 2024, 12:22pm
5
Hi @craigmartin
We have to first split the sample text with the line break… that will be stored in string arrays str_arr as str_arr[0],str_arr[1], str_arr[2], str_arr[3]
Then you have split each of these again with a comma seperator.
For eg ( (str_arr[0].Tostring).split(“,”)). Tostring will give you now only that specific row value.
Hope this finds you helpful
pikorpa
(Piotr Kołakowski)
February 17, 2024, 1:15pm
6
Hey @craigmartin
check below solution:
allText.Split(New String() {vbCrLf, vbCr, vbLf}, StringSplitOptions.RemoveEmptyEntries)
BlankProcess105 (2).zip (10.3 KB)