Regex to get the words after matching string

Below is the content:

Subject:
Security ID: S-1-5-21-3368353891-1012177287-890106238-22451
Account Name: ChamaraKer
Account Domain: JIC
Logon ID: 0x1fffb

Object:
Object Server: Security
Object Type: File
Object Name: D:\ApacheTomcat\apache-tomcat-6.0.36\logs\localhost.2013-07-01.log
Handle ID: 0x11dc

I need to capture the words after the Object Name: word in that line.
Which is: D:\ApacheTomcat\apache-tomcat-6.0.36\logs\localhost.2013-07-01.log

Anyhelp?

Hey @Woodson_Louis

Below is the regex which will help you

(?<=Object Name: ).*(?=\n+?)

Below is the output Screenshot

So the explanation of above regex is
It will get all the contents which are present after Object name:
and will capture all the content until it meets new line

Hope it helps You!

Happy automation :smile:

1 Like

Hello @Woodson_Louis! Try this:
Object Name:\s*(.*)

Cheers!

1 Like

Hi @Woodson_Louis

Use the below expression

(?<=Object Name.\s+).*

Hope it works!!

1 Like

1 Like

Hi @Woodson_Louis

Check the below regex expression to extract the required output from Input string.
I have used look a head function to get the data after the Object Name: then it will extract the required text.

System.Text.RegularExpressions.Regex.Matches(yourstringinput.ToString,“((?<=Object Name:\s+).*)”)

Hope it helps!!

1 Like

Hi @Woodson_Louis

Try this

(?<=Object Name: ).*

Regards,

1 Like

@Woodson_Louis

System.Text.RegularExpressions.Regex.Match(“YourInputString”,“(?<=Object Name:\s).*.log”).Value

1 Like

Thank you @Woodson_Louis

If you find the solution for your query make mark it as solution which helps to other.

Happy Automation!!

Hi @Woodson_Louis

If you find the solution for your query please mark as solution to close the loop.

Regards

Thanks to all og you guys for your help! You guys are genius!! Thanks again @rlgandu @lrtetala @mkankatala @ppr @vrdabberu @rodrigo.simao :grinning:

2 Likes

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