views:

86

answers:

6

in my application i have a text box in that '123456789v' first 9 charecter must be digits after that any character or a particular character how can i write please help me. thank u

+1  A: 

Somthing like: [0-9]{9}.

Or if the last character must be an alpha character: [0-9]{9}[a-z]

If you are new to regular expression I sujest you get your hands on a tool to help you with them. I personaly like this Expresso: http://www.ultrapico.com/Expresso.htm but you can also google for a "regex designer" as there a number of good ones online.

Geoff
ok mr.Geoff it is workin but i need 9 digits and one character should any alphabet thank u for response
Surya sasidhar
A: 

Perhaps something like this may help.

^[0-9]{9}.

EDIT: Removed escape characters.

Rahul
hai rahul it is not working
Surya sasidhar
+1  A: 

How about: \d{9}.

Edit: Explained the regex:

\d = Any digit
{9} = 9 times
. = Any character
Scoregraphic
mr.Scoregraphic it is working when i type 1 to 9 digits after that i type a alphabet it is giving error message
Surya sasidhar
Please provide some test input/code as it works for me. Best would be to edit the question
Scoregraphic
ya it is working mr.scoregraphic
Surya sasidhar
A: 

I'd say

^\d{9}[A-Za-z]$

To match 9 digits and one alphabetic character, and nothing before or after.

Ledhund
ya it is working tahnk u mr.ledhund
Surya sasidhar
+1  A: 

If the last character must be a alphabet:

^[0-9]{9}[a-zA-Z]$

If the last character can be anything other than a number

^[0-9]{9}[^0-9]$
o.k.w
thank u it is working mr.o.k.w
Surya sasidhar
@Surya, you are welcomed. Glad I am of help.
o.k.w
A: 
Regex r = new Regex("[0-9]{9}[a-zA-Z]$");
label1.Text = r.IsMatch(textBox1.Text).ToString();

If specific character then:

[0-9]{9}v$
NinethSense
ok thanku u it is working mr.Ninethsense
Surya sasidhar