troubleshooting Question

C# Regular expression for matching text across multiple lines

Avatar of orion7999
orion7999 asked on
8 Comments2 Solutions2191 ViewsLast Modified:
I have the following text that i need to parse.

service xyz_1234
  ip address

  protocol tcp

  port 0000


I need to match
service xyz_1234
  ip address
with a regular expression

I am having problem as the IP address is on a newline.

HEre is the regular expression I tried. It didnt work.

Regex.Match(str, @"service xyz_1234\s*\r\r\s*ip address\s*(?<ig>\w+\.\w+\.\w+\.\w+)");

Please let me know where I am going wrong.
Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros