Answers for "Match one of 1, 2, x or X, or nothing"

C#
0

Match one of 1, 2, x or X, or nothing

private Boolean patternIsMatch(String text) {
	// Alternatives; one of 1, 2, x or X, or nothing is accepted pattern.
	Regex pattern = new Regex(@"^([12xX]{1}|^)$");
	return pattern.IsMatch(text);
}
Posted by: Guest on May-07-2022

C# Answers by Framework

Browse Popular Code Answers by Language