Try this might be you get some help.
public static void Main()
{
var str1 = "XXX.XXX.test.com.X1";
var str2 = "Y.YY.google.co.in.X2";
var str3 = "ZZ.ZZZ.google.co.in";
var str4 = "PPPP.P.Yahoo";
var str5="XX.XXX.test.com.Y1";
var str6="Y.YY.google.co.in.X2";
var str7 ="Y.YY.google.co.in.XX";
var regex = new Regex(@".[XY][0-9a-zA-Z](.*)", RegexOptions.Singleline);
str1=string.Join(".", str1.Split('.').Skip(2).ToArray());
str2=string.Join(".", str2.Split('.').Skip(2).ToArray());
str3=string.Join(".", str3.Split('.').Skip(2).ToArray());
str4=string.Join(".", str4.Split('.').Skip(2).ToArray());
str5=string.Join(".", str5.Split('.').Skip(2).ToArray());
str6=string.Join(".", str6.Split('.').Skip(2).ToArray());
str7=string.Join(".", str7.Split('.').Skip(2).ToArray());
Console.WriteLine(regex.Replace(str1, ""));
Console.WriteLine(regex.Replace(str2, ""));
Console.WriteLine(regex.Replace(str3, ""));
Console.WriteLine(regex.Replace(str4, ""));
Console.WriteLine(regex.Replace(str5, ""));
Console.WriteLine(regex.Replace(str6, ""));
Console.WriteLine(regex.Replace(str7, ""));
}
See this demo as well
Output like below:
test.com
google.co.in
google.co.in
Yahoo
test.com
google.co.in
google.co.in
3
solved split string with having dot as deliminator and dot in value as well [closed]