I have a text field which feeds into a label through code. As the user types text into the field, it will automatically parse the text, and strip out non-word characters from the text and place it into the label.
private void text_KeyUp(object sender, KeyEventArgs e)
{
label.Content = Regex.Replace(text.Text, @"[^\w]", "").ToLower();
}
However, I have another constraint to this label field, and I can't figure out how to do it. The current RegEx I have makes it so the label can only have lowercase word characters. However, I also need to make sure the first character in the label is not a number. I have tried ^[^A-Za-z][^\w]
, but that isn't working. Anyone got any ideas?