Shaiju T
Shaiju T

Reputation: 6609

regular expression string starts with a letter in mvc

i am trying to validate if string starts with letter k, followed by anything

Expected output :

khtjk
k1234
kq12g

i followed this and this, but it doesnt allow anything after k

this is what i tried :

[RegularExpression("^k", ErrorMessage = "Sorry, enter correct bill no")]
public string StoreBillNo { get; set; }

any help would be great.

Upvotes: 1

Views: 1851

Answers (1)

Ehsan Sajjad
Ehsan Sajjad

Reputation: 62488

You have to use this regex for capital and small case:

^[kK].*

or use ignore case :

/^k.*/i

OR

"(?i)^k.*"

Upvotes: 3

Related Questions