Hell Team,
I have string s= "receivedfrom UDP: [10.36.15.60]:1024->[10.108.247.97]:162";
From this, I need to fetch 10.36.15.60 via regex.
Please help on this.
Thanks and Regards,
Hari
Hell Team,
I have string s= "receivedfrom UDP: [10.36.15.60]:1024->[10.108.247.97]:162";
From this, I need to fetch 10.36.15.60 via regex.
Please help on this.
Thanks and Regards,
Hari
Try a simple approach too:
string s = "receivedfrom UDP: [10.36.15.60]:1024->[10.108.247.97]:162";
var m = Regex.Match( s, @"^receivedfrom UDP: \[(.+?)\]" );
string result = m.Success ? m.Groups[1].Value : null;
It can be improved using a more complex expression depending on problem details.
Hello Viorel,
Thanks for answer.
But regex is not working as there is a typo in my string. Refer attached image.
You can find some 19 spaces between receivedfrom and UDP?
Thanks and Regards,
Hari
To support such strings too, try this pattern: @"^\s*receivedfrom\s+UDP:\s*\[(.+?)\]".
Hello Viorel,
Thanks. It is working.
I have one more requirement:
From the above screenshot, I need to fetch the highlighted part and maintain in Dictionary key and value.
Like dictionary.Add("ifIndex.19", "19").
Please help on this via regex.
Thanks and Regards,
Hari
Hello Viorel,
Thanks. It is working my initial request.
Best Regards,
Hari
10 people are following this question.
Insert a node as child ,before or after a node in nested dynamic JSON Node using C#
Visual Studio 2019: Undefined behavior in a C++/CLI wrapper project.
Example for how to get Package Metadata from Azure DevOps Rest-Api Artifacts using c#
How to collapse individual nested grids/stackpanels inside a grid?