Need to fetch only the Numbers from paragraph

I have paragraph need to fetch number from them
For example
A ID 12345 has match with the other id 6789.
My output should be:
12345
6789

I ihave more than one para
A ID 12345 has match with the other id 6789.And 34567 matches with requirements 4567 matches with requirements 567 matches with requirements.
My output should be:
12345
6789
34567
4567
567

I need to arrange first numbers in one data table and remaining in another data table
In first example:
12345 should store in dt_results1
6789 should store in dt_results2

For second example
12345
should store in dt_results1
6789
34567
4567
567
should store in dt_results2

@sruthesanju

(?<=\s)\d+

I have edited the condition can you pls explain for that one

@sruthesanju
Main.zip (3.0 KB)


In that please disable ignore case

Hi @sruthesanju

I made a workflow as per your requirement. Check the below steps for better understanding,
→ Use the assign to store the Input Text in a variable called InputString,

- Assign -> InputString = "A ID 12345 has match with the other id 6789.And 34567 matches with requirements 4567 matches with requirements 567 matches with requirements
                           A ID 12345 has match with the other id 6789."

→ Use the Build datatable activity to intitialize a datatable called dt_result1 and create a column called Extracted Numbers.
→ Then use another Build datatable activity to initialize a datatable called dt_result2 and create a column called Extracted Numbers.
→ Then take an assign activity and give the below LINQ Expression to store the data in dt_results1,

- Assign -> dt_results1 = System.Text.RegularExpressions.Regex.Matches(InputString, "(?<=ID\s+)\d+", System.Text.RegularExpressions.RegexOptions.Multiline).Cast(of System.Text.RegularExpressions.Match).Select(Function(X) dt_results1.Rows.Add(X.ToString().Trim())).CopyToDataTable()

→ Then take an another assign activity and give the below expression to store the extracted data in dt_results2,

- Assign -> dt_results2 = System.Text.RegularExpressions.Regex.Matches(InputString, "(?<=.*\d+\s+[A-Za-z]+.*)\d+", System.Text.RegularExpressions.RegexOptions.Multiline).Cast(of System.Text.RegularExpressions.Match).Select(Function(X) dt_results2.Rows.Add(X.ToString().Trim())).CopyToDataTable()

→ Then use the write range workbook activity to write the data in dt_results1 in Sheet1.
→ Use another write range workbook activity to write the data in dt_results2 in Sheet2.

Check the below workflow for better understanding,
Sequence2.xaml (17.6 KB)

Check the below output file, (Sheet1 contains dt_results1 data and Sheet2 contains dt_results2 data),
Dummy Data.xlsx (8.9 KB)

Hope it helps!!

What if my input is like this
A ID 12345 has match with the other id 6789:34567 matches with requirements1 4567 matches with requirements2 567 matches with requirements

My output should be:
12345 should be in dt_results1
34567
4567
567
Should be in dt_results2

No it will change 6789 1 and 2 also will add to dt_results2… @sruthesanju

If you show me the proper input and expected output then we can easily understand.

This is the input format requirements2 and requirment 1 I should not include

After the first ID 1234 other all number should be store in results 2 except like this requirement 1 should not be stored

@sruthesanju

Please specify all your requirements once because the regular expressions changes every time .

This is the given input

Okay got it… @sruthesanju

Can you change the expression for the second assign activity to assign for the dt_results2,

- Assign -> dt_results2 = System.Text.RegularExpressions.Regex.Matches(InputString, "(?<=.*\d+\s+.*)\d{2,}", System.Text.RegularExpressions.RegexOptions.Multiline).Cast(of System.Text.RegularExpressions.Match).Select(Function(X) dt_results2.Rows.Add(X.ToString().Trim())).CopyToDataTable()

By changing this one expressions in the workflow you will reach your requirements.

Check the below image for better understanding,
image

Hope you understand!!

A ID 12345 has match with the other id:
34567 matches with requirements1 4567 matches with requirements2 567 matches with requirements

If it is like this I am not getting the value after :
34567 I am not getting

Give me all your input data based on that we will right a regular expressions based on all the data… @sruthesanju

A ID 12345 founds with percentage for the given need requirements:
2345 requirements needed for enroll.
123456 requirements needed for matches1.

12345 should be in dt_results1

Remaining should be in dt_results2

Okay @sruthesanju

Change the expression for the second assign activity which is assigning for dt_results2,

- Assign -> dt_results2 = System.Text.RegularExpressions.Regex.Matches(InputString, "(?<!ID\s+)\b\d{3,}\b", System.Text.RegularExpressions.RegexOptions.Multiline).Cast(of System.Text.RegularExpressions.Match).Select(Function(X) dt_results2.Rows.Add(X.ToString().Trim())).CopyToDataTable()

Check the below output it may satisfy your requirement,
image

Hope it helps!!

It’s works thank you

1 Like

It’s my pleasure… @sruthesanju

Happy Automation!!

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