Ask about code for Regex data pdf to excel

I want to change data pdf to excel
like this below.

203823 624 799 236 397 50

I got all digits in one line by using
(\d{6})\s(\d{3})\s\s(\d{3})\s\s(\d{3})\s\s(\d{3})\s(\d{2})

but it = I selected all

how to select
203823 =column or row 1
624 column or row 2
799 column or row 3
236 column or row 4
397 column or row 5

if you have video recommended , thk so much

1 Like

Use the “Assign” activity to create a variable of type String[] (an array of strings). Let’s call it numbersArray and set its value using the “Split” method to split the inputText based on spaces.
numbersArray = inputText.Split(" "c)
Use a “For Each” activity to loop through the numbersArray

Hey @Suniagoz ,
You can break the input text to a list or an array by using string manipulation functions such as Spilt.
In this case You spilt the input text based on spaces and you get an array or list
Then iterate through it

for ex
:After splitting your input list will be {203823, 624, 799, 236, 397, 50}

And then u can use index to access those texts

Hi @Suniagoz

Use the split function to split the values by using space and store it in to a array.
Use build datatable activity to build one datatable. In that datatable create a column with any column name.
Iterate the array variable which stored the splitted data and data to the each row by using add data row activity.

I have developed the workflow for your reference. Check the below image and attached xaml file.

Output File in excel check below
image

Browser_Practice.xaml (11.5 KB)

Hope it helps!!

@Suniagoz

  1. build one datatable DT and give column name
  2. use one assign activity and make array variable
    ArrayVar=split(yourCurrVar, " ")
    3 use for each over ArrayVar
  3. inside loop use Add data row and give table as DT and in Array section give like this
    {Item}
  4. after loop add write range and give file name and DT to store it in excel

@Suniagoz

Use the split and pass all the number to array of string variable and then using the for each you can recall the numbers individually.
Regards

Here are few Youtube links for you to refer

Hi @Suniagoz

  1. Convert matches to array by using this expression:
Arr_str = (From m in matches.Cast(of Match).ToArray()
Select Convert.ToString(m)).ToArray()

or
Directly use split function to split the data by spaces and store it in an array.
2. Use for each loop to iterate through the array and use write cell activity in the loop.

Hope it helps.

Hi @Suniagoz

Try this

I hope it helps!!

@Suniagoz

Use find matches activity

Build datatable

\d{2,6}

Take for each loop
Add datarow

Outside for each
Write range

Hi @Suniagoz ,

We can access the individual value captures by accessing the Groups as the groupings are already done in regex expression :

A slight modification on Regex :

(\d{6})\s+(\d{3})\s+(\d{3})\s+(\d{3})\s+(\d{3})\s+(\d{2})

Accessing values in Studio :

System.Text.RegularExpressions.Regex.Match(strVar,"(\d{6})\s+(\d{3})\s+(\d{3})\s+(\d{3})\s+(\d{3})\s+(\d{2})").Groups(1).ToString

Visuals :
image

@Suniagoz

Use a generate datatable activity and then give the column seprator as space

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.