here is your complete solution
string s = "Hello Anis PID=27HMJ-GH7P9-X2TTB-WPHQC-RG79R is a pattern";
s = Regex.Replace(s, @"(P)(I)(D)(=)[A-Z0-9]{5}(-)[A-Z0-9]{5}(-)[A-Z0-9]{5}(-)[A-Z0-9]{5}(-)[A-Z0-9]{5}","[Your replacement String]", RegexOptions.IgnoreCase);
Out put will be "Hello Anis [Your replacement String] is a pattern" for all matching
pattern like(PID=27HMJ-GH7P9-X2TTB-WPHQC-RG79R)
happy coding :)