A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Hello,
The best way to match a particular string is to match with a regular expression.
On MAUI, you could refer to the following simple code to match the specific characters.
private void myEntry_TextChanged(object sender, TextChangedEventArgs e)
{
Regex regex = new Regex(@"^[a-zA-Z]{2}\d{5}");
if (e.NewTextValue != null && e.NewTextValue.Length == 7)
{
if (!regex.IsMatch(e.NewTextValue))
{
test.Text = "Not Match!";
}
else
{
test.Text = "Matched";
}
}
else
{
test.Text = "Not Match!";
}
}
You could refer to this official documentation to get more details: Regex Class.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.