-5

I need to write a regex for a text-box field validation on the JSF page. I need this field to be an empty, or contains a sequence of [a-z]1[a-z]54. How can I do that?

St.Antario
  • 26,175
  • 41
  • 130
  • 318

3 Answers3

4

You could try this also,

^([a-z]1[a-z]54)?$

? after the capturing group would make the whole capturing group as an optional one.

DEMO

Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
3

try this one: ^([a-z]1[a-z]54|)$

vks
  • 67,027
  • 10
  • 91
  • 124
Jasen
  • 11,837
  • 2
  • 30
  • 48
2

This regex may help you ^[a-z]{1,54}$|^$

Guillaume S
  • 1,462
  • 2
  • 19
  • 31