How to get match string or value by using Regex?

Hi Everyone,

I need data from email body and I am trying to using RegEx for get matched value.

Scenario:- I am using dummy data for reference

Is this relavent to Test1 or Test2? Abc
Is this uipath request? Yes
Is this Bill or Letter? Letter
Enter your name-RPA Uipath
Enroll Number- 123-456-789-65
Guider’s Name- xyz
Where should we send this request? Please enter the email address - Test@gmail.com

So, I want to get value after “?” in every new line. for example:-
Is this relavent to Test1 or Test2? Abc

How to get this value by using Regex?
Can anyone give suggestion?
So, I want “Abc” value from first line.

give a start try on:

For last line, I do not want to get data after “?” I want only emailId.

Where should we send this request? Please enter the email address -Test@gmail.com

Actually When I am trying this expression (?<=-).* , so this is fetch data from last line and that I don’t need after ?

vs

so requirement is more to fix in advance. Now it is depending more on the new requirment if the pattern will be handling all specifics or is more to open and the matches are reprocess for more strict extractions

Just have also a look on following outcomes and feel free to combine the different options

Or

with reference to group1
grafik

In this case you dont need much more solution! You can use the .Take() Method

<your_match_group>.Take(6)

Then you get your ocurrencer without last line of the answer. At the same time you can get email pattern regex to get the email.

Regards!!

Hey

If you want to learn Regex - check out my MegaPost.

Hopefully this helps you on your automation journey :blush:

1 Like

This is very useful.
Thank you @Steven_McKeering , @ppr and @gabrielribas4 for helping. All your solution helpful to understand Regex.

1 Like

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