Click here to Skip to main content
15,914,408 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear friends,

i'm trying to block numeric value input form txtbox using regular expression
i need allowed numbers with *

ex - 444 - not allowed
*444* - allowed


can anyone help me.

here is my code. i have tried but it's not working


C#
else if (!Regex.IsMatch(txtLunchinput.Text, ".*[a-zA-Z]+.*"))
            {
                MessageBox.Show("Wrong!");
                return;
            }
Posted
Updated 16-Jun-15 17:20pm
v2
Comments
Sergey Alexandrovich Kryukov 17-Jun-15 0:01am    
This example does not define what is allowed and what not. You need to provide a string definition of the rule. Idea?! What have you tried so far?
—SA

Please see my comment to the question.
Some hints for you: 1) * should be escaped; 2) dot (.) means "any character", not sure this is what you want.

I think this would be enough for you.

—SA
 
Share this answer
 
Comments
Neranjana pathirana 18-Jun-15 1:08am    
thanks for your answer. but it also not working
Sergey Alexandrovich Kryukov 18-Jun-15 9:57am    
What is "not working", exactly? If you need more help, you need to 1) show what have you tried so far?, 2) defined what you want to achieve; define, not just illustrate.
—SA
This is trivial. Find your answer by learning from The 30 Minute Regex Tutorial[^]
 
Share this answer
 
Comments
Neranjana pathirana 18-Jun-15 1:07am    
yes. thanks it's help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900