How to extract the data using regex

Hi team I need to extract the data Chethan P from below paragraph

This is to certify that

Chethan P

has successfully completed the training module

Thanks
Chethan P

Try Name = System.Text.RegularExpressions.Regex.Match(inputString, “(?<=that\n\n).*”)

1 Like

Will this text always available in the first line?? and will there a line space after the first line always??

1 Like

the text is the same as above only the name will change and enter will be there the same format but we have to extract the name only
This is to certify that

Name (Chethan P)

has successfully completed the training module

The only name that will change we can use look behind and look ahed

ya i use this code i get error object reference is not set to an instance of object

Write Line: Object reference not set to an instance of an object.

Thanks
Chethan P

@copy_writes - Please try this…

image

Just code : OpRex(0).value → This is equivalent to string. You dont need .tostring again…

1 Like

Could you please share the code

I would to suggest to give it a try. If you face any error please let us know…

1 Like

ya I get the error the its not matching any words soma asking regex code

@copy_writes - You have to choose ECMAScript…

https://regex101.com/r/pgL4wz/1/

1 Like

Ya i use this I get the error like this


but the value is came from the pdf extraction i check that in message box its showing but still am get this error

@copy_writes - it is working for me for the text you have to provided…

I use read pdf and in that the value is present i dont know what happen in matches


When you give the hard code value on that time its working when you send the data through variable on that time its through error

@copy_writes - i guess, something is not printing from your pdf correctly/differently…Could you please try the below…

(?<=certify that\r?\n?\r?\n?).+

If this is not working…Write text pdf output to text file and share the text file please…

C.txt (185 Bytes)

@copy_writes - Please see this…I haven’t changed anything in the code…just added your text file…

Why don’t you Assign a string variable to the expression I provided earlier… should not give any errors. Just use System.Text.RegularExpressions.Regex.Match(inputString, “(?<=that\n\n).*”) where inputString is your ReadPDF output and assign it to a variable of type String.

1 Like

@copy_writes - Here you go…
Regex_Chetan.xaml (5.5 KB)

1 Like

ya i got the op but if i give OpRex(0).value its not coming the op is null
if give OpRex(2).value the op is coming

image
image