Created
October 26, 2013 17:41
-
-
Save YounesCheikh/7172385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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]))";