How can i get the specific value from an String using Regex?

I want to get Barcode from an String using Regex. Can any one please help me how to do it ??

Thanks

Can u provide the input and expected output String

1 Like

This is my String :

"El\r\nJERNST&YOUNC Expense Report\r\nI Date Prepared : 12—05—2020 I Business Unit : 1N1 1 1 Expense Report Number : 2173300892 I\r\nI Submitted : 20—05—2020 I Management Unit : 00167 I\r\nI GPN - Name I 1N010M48053 - Vinayak Aggarwal I Sub Management Unit : 0316068 I\r\nI Signature: I Approved By : I\r\nI Rank : Staff/Assistant—Grade 4 I Rank : I\r\nI Expense Details (AnaCh supporting reccipts) I I C = Chargeable P = Authorized I\r\n.otal Expense\r\nI L.p. IExpense Type I Date I Description I Location 1| Location 2 I I Type I Engagement I Activity |\r\n1 International Travel-Billable - 05-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,497.47 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 05/05/20\r\nDaily rental taxi expenses ~ CAD 79.70 CAD = INR\r\n4497.47\r\n2 International Travel-Billable - 06-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,542.61 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 06/05/20\r\nDaily rental taxi expenses ~ CAD 80.50 CAD = INR\r\n4542.61\r\n3 International Travel-Billable - 07-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,532.81 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 07/05/20\r\nDaily rental taxi expenses ~ CAD 80.17 CAD = INR\r\n4532.81\r\n4 International Travel-Billable - 08-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,536.97 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 08/05/20\r\nDaily rental taxi expenses ~ CAD 80.40 CAD = INR\r\n4536.97\r\n5 International Travel-Billable - 1 1-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,547.59 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 11/05/20\r\nDaily rental taxi expenses ~ CAD 80.46 CAD = INR\r\n4547.59\r\nI | | | I | I I I | I\r\nTotals (INR) I 206,455.77 I\r\nAdvance money/ prepayment I I\r\nPayment/Retum I I\r\n2173300892\r\nPage 1 of 3El\r\nJERNST&YOUNC Expense Report\r\nI Date Prepared : 12-05-2020 I Business Unit : 1N1 1 1 Expense Report Number : 2173300892 I\r\nI Submitted : 20—05—2020 I Management Unit : 00167 I\r\nI GPN - Name I IN010M48053 - Vinayak Aggarwal I Sub Management Unit : 0316068 I\r\nI Signature: I Approved By : I\r\nI Rank : Staff/Assistant—Grade 4 I Rank : I\r\nI Expense Details (AnaCh supporting reccipts) I‘otal ExpenseI C = Chargeable P = Authorized I\r\nI L.p. IExpense Type I Date I Description I Location 1| Location 2 I I Type I Engagement I Activity |\r\n6 International Travel-Billable - 12-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,545.99 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 12/05/20\r\nDaily rental taxi expenses ~ CAD 80.46 CAD = INR\r\n4545.99\r\n7 International Travel-Billable - 12-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 78,268.47 P 39981687 0000 - General\r\nLodging _ Lodging Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 Canada -\r\nHotel accommodation: amex reimbursement\r\nVancouver - 5thMay-12thMay 2020~CAD 1390.06 =\r\nINR 78268.47\r\n8 International Travel-Billable - 13-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,573.91 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 13/05/20\r\nDaily rental taxi expenses ~ CAD 80.94 CAD = INR\r\n4573.91\r\n9 International Travel-Billable - 14-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,528.05 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 14/05/20\r\nDaily rental taxi expenses ~ CAD 80.10 CAD = INR\r\n4528.05\r\nTotals (INR) I 206,455.77 I\r\nAdvance money/ prepayment I I\r\n* * Payment/Retum I I\r\n| 2173300892 |\r\nPage 2 of 3El\r\nJERNST&YOUNC Expense Report\r\nI Date Prepared : 12-05-2020 I Business Unit : 1N1 1 1 Expense Report Number : 2173300892 I\r\nI Submitted : 20—05—2020 I Management Unit : 00167 I\r\nI GPN - Name I IN010M48053 - Vinayak Aggarwal I Sub Management Unit : 0316068 I\r\nI Signature: I Approved By : I\r\nI Rank : Staff/Assistant—Grade 4 I Rank : I\r\nI Expense Details (AnaCh supporting reccipts) I I C = Chargeable P = Authorized I\r\n.otal Expense\r\nI L.p. IExpense Type I Date I Description I Location 1| Location 2 I I Type I Engagement I Activity |\r\n10 International Travel-Billable - 15-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,563.58 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 15/05/20\r\nDaily rental taxi expenses ~ CAD 80.70 CAD = INR\r\n4563.58\r\n1 1 International Travel-Billable - 18-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,488.32 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 18/05/20\r\nDaily rental taxi expenses ~ CAD 80.12 CAD = INR\r\n4488.32\r\n12 International Travel-Billable - 19-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 78,327.10 P 39981687 0000 - General\r\nLodging _ Lodging Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 Canada -\r\nHotel accommodation: amex reimbursement\r\nVancouver - 12thMay-19thMay 2020\r\n~CAD 1390.06 = INR 78327.10\r\n13 International Travel-Billable - 19-05-2020 Project Agrium- Nutrien Project Foundation HLD CAN BC 4,502.90 P 39981687 0000 - General\r\nGround Transportation _ Taxi Employer :Emst & Young LLP United States\r\nEngagement name : Agrium- Nutrien Project\r\nFoundation HLD Charge Code : 65411594 19/05/20\r\nDaily rental taxi expenses ~ CAD 80.28 CAD = INR\r\n4502.90\r\nTotals (INR) I 206,455.77 I\r\nAdvance money/ prepayment I I\r\n* * Payment/Retum I I\r\n| 2173300892 |\r\nPage 3 of 3Uber Tue, May 05, 2020 U ber Tue, May 05, 2020\r\n, . . , . .\r\nHere 5 your receipt for you r m p Here 5 your receipt for you r m p\r\nWe’re glad to have you as an Uber Rewards Gold member. We’re glad to have you as an Uber Rewards Gold member.\r\nTotal CA$39.48 Total CA$40.22\r\nTrip fare CA$29.89 Trip fare CA$30.58\r\nSubtotal CA$29.89 Subtotal CA$30.58\r\nGST CA$2.09 GST CA$2.14\r\nTolls, Surcharges, and Fees CA$7.50 Tolls, Surcharges, and Fees CA$7.50\r\nAmount Charged Amount Charged\r\n[351-4005 CA$39-48 Gimmes CA$40.22\r\nBASfljihegdpjago for more information, including invoices [Where available) liflmgdpjago for more information, including invoices (Where available)\r\nYou rode with Sean You rode with Adriel\r\nUberX 21.54 kilometres | 26 min(s) UberX 21.61 kilometres | 29 min(s)\r\nI 07:35 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada I 16:50 | 7430, Hopcott Rd. Delta, BC V4G 1B6, Canada\r\nI 08:01 | 7430, Hopcott Rd. Delta, BC V4G 1B6, Canada I 17:19 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada\r\nFare does not include fees that may be charged by your bank. Please contact your bank directly forinquiries. Fare does not include fees that may be charged by your bank. Please contact your bank directly for inquiries.Uber Wed, May 06, 2020 U ber Wed, May 06, 2020\r\n, . . , . .\r\nHere 5 your receipt for your trip Here 5 your receipt for your trip\r\nWe’re glad to have you as an Uber Rewards Gold member. We’re glad to have you as an Uber Rewards Gold member.\r\nTotal CA$39.66 Total CA$40.84\r\nTrip fare CA$30.06 Trip fare CA$31.16\r\nSubtotal CA$ 30.06 Subtotal CA$31.16\r\nGST CA$2.10 GST CA$2.18\r\nTolls, Surcharges, and Fees CA$7.50 Tolls, Surcharges, and Fees CA$7.50\r\nAmount Charged Amount Charged\r\n[EKMOOB CA$39.66 3:9,“2008 CA$40.84\r\nBASfljihegdpjago for more information, including invoices [Where available) liflmgdpjago for more information, including invoices (Where available)\r\nYou rode with Riley You rode with Archer\r\nUberX 21.64 kilometres | 26 min(s) UberX 21.60 kilometres | 27 min(s)\r\nI 07:30 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada I 17:01 | 7430, Hopcott Rd, Delta, BC V4G 1B6, Canada\r\nI 07:56 | 7430, Hopcott Rd. Delta, BC V4G 1B6, Canada I 17:28 | 1000, Burrard St, Vancouver, BC V62 2R9, Canada\r\nFare does not include fees that may be charged by your bank. Please contact your bank directly forinquiries. Fare does not include fees that may be charged by your bank. Please contact your bank directly for inquiries.Uber Thu, May 07, 2020 U ber Thu, May 07, 2020\r\n, . . , . .\r\nHere 5 your receipt for your trip Here 5 your receipt for your trip\r\nWe’re glad to have you as an Uber Rewards Gold member. We’re glad to have you as an Uber Rewards Gold member.\r\nTotal CA$39.62 Total CA$40.55\r\nTrip fare CA$30.02 Trip fare CA$30.89\r\nSubtotal CA$ 30.02 Subtotal CA$30.89\r\nGST CA$2.10 GST CA$2.16\r\nTolls, Surcharges, and Fees CA$7.50 Tolls, Surcharges, and Fees CA$7.50\r\nAmount Charged Amount Charged\r\n[EKMOOB CA$39.62 3:9,“2008 CA$40.55\r\nBASfljihegdpjago for more information, including invoic…

and output is 2173300892 this one.

Please list the expected outputs below the above input string.

Please also give as much information about the characteristics of the output. Length, does it change? and letters in the outcome?

Hello Steven,

I want (2173300892) if that is like this - Payment/Retum I I\r\n2173300892\r\nPage 1

(?<=Expense Report Number : )\d+
Link to review

1 Like

Payment/Retum I I\r\n VARIABLE \r\nPage 1

Are all these characters fixed? Will they ever change?

The Length is always same and it will be always number Steven.

All are fixed

Hello

Try this:

Payment/Retum I I\r\(.+)\r\nPage 1

Regex101 Link to review

Replace ‘INSERTVARIABLE’ with your output variable from the matches output variable.

Match 1:

INSERTVARIABLE(0).Groups(1).ToString

1 Like

Bro. i do not want to get that value from Expanse Report Number, i want to get that from the down of this PDF file. Please find the attached pdf file.

Thanks

Okay, see above post #10

Let me try and refine.

Hi @mitradev_das

Okay, try this piece of Regex:
(?<=Payment/Retum I I\r\).{11}(?=\r\nPage)

Here is the Regex101 Link

It uses a positive look behind and a positive lookahead to lock in the 11 characters between these text. (it will match any 11 characters)

Write out the result using the following:
INSERTVARIABLE(0).tostring

2 Likes

The regex code is correct but i am not able to get the output. Getting this error message : The Object Reference is not set to an instance of an object when i am passing <output(0).ToString> inside a message Box activity.

It means the output is not getting a match.

Double check Input text and Regex pattern.

If you are still having problems upload your xaml file.

Extract_PDF_Test-xaml.zip (3.0 KB)

This is my workflow. Could you please check and let me know what’s wrong in this Workflow.

Thanks

1 Like

can you try UiPathTeam.BarCode package ???

Sorry bro can not use this activity.

Hello @Steven_McKeering

Can you please tell me how can i extract all those bellow 13 data’s from this pdf file ??

  1. Date Prepared
  2. Submited
  3. GPN - Name
  4. Rank
  5. Business Unit
  6. Management Unit
  7. Sub Management Unit
  8. Expanse Type
  9. Description
  10. Total Expenses
  11. Type
  12. Engagement
  13. Activity