Simple Regex question
-
I'm trying to verify if a character is a letter. Regex.IsMatch("3", "[a-zA-z]") returns TRUE when it should be FALSE. What am I doing wrong? thanx
-
I'm trying to verify if a character is a letter. Regex.IsMatch("3", "[a-zA-z]") returns TRUE when it should be FALSE. What am I doing wrong? thanx
-
I'm trying to verify if a character is a letter. Regex.IsMatch("3", "[a-zA-z]") returns TRUE when it should be FALSE. What am I doing wrong? thanx
>>> Regex.IsMatch("3", "[a-zA-z]")
falseWorks for me. There must be something else wrong with your code.
-
I'm trying to verify if a character is a letter. Regex.IsMatch("3", "[a-zA-z]") returns TRUE when it should be FALSE. What am I doing wrong? thanx
Ok, the following code worked for me. I created a Windows Form with a textbox control and a button. Check it out:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}private void button1\_Click(object sender, EventArgs e) { if (Regex.IsMatch(textBox1.Text, @"\[a-zA-z\]") == false) { MessageBox.Show("false - input is numeric."); } else { MessageBox.Show("true - input is non-numeric."); } } }
}
hope this helps. Jay.
foreach( inch on Jason ) { Girlfriend.IsHappier(); }