Skip to content

Instantly share code, notes, and snippets.

@YounesCheikh
Created October 26, 2013 17:41
Show Gist options
  • Save YounesCheikh/7172385 to your computer and use it in GitHub Desktop.
Save YounesCheikh/7172385 to your computer and use it in GitHub Desktop.
static void Main(string[] args)
{
string pattern = @"^\((0*([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]),){2}0*([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\)$";
string input1 = @"(255,254,255)";
string input2 = @"my color is (255,254,255) in rgb";
input1 = Regex.Replace(input1, pattern, "MY_COLOR", RegexOptions.IgnoreCase);
input2 = Regex.Replace(input2, pattern, "MY_COLOR", RegexOptions.IgnoreCase);
Console.WriteLine(input1); // Result: "MY_COLOR"
Console.WriteLine(input2); // Result: "my color is (255,254,255) in rgb"
// I want to get : "my color is MY_COLOR in rgb"
}
@YounesCheikh
Copy link
Author

string pattern = @"((0_([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]),){2}0_([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5]))";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment