I have a requirement to find a text pattern [anystring].[anystring] with in a larger text.
I wrote a regex code to achieve this
var pattern = @"\[(.*?)\]\.\[(.*?)\]";
string CustomText = "some text here [anystring].[anystring] some text here etc"
var matchesfound = System.Text.RegularExpressions.Regex.Matches(CustomText, pattern);
This code works fine and detects the "[string].[string]" pattern but it fails for this
var pattern = @"\[(.*?)\]\.\[(.*?)\]";
string CustomText = "[somestring]=[anystring].[anystring]"
var matchesfound = System.Text.RegularExpressions.Regex.Matches(CustomText, pattern)
In the above scenario, it identifies the whole string "[somestring]=[anystring].[anystring]" but I want only "[anystring].[anystring]" to be identified as match. Any help with this please? Thank you.
\[([^][]*)\]\.\[([^][]*)\]