-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
  • 24,791
  • 31
  • 112
  • 278

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
  • 166,785
  • 24
  • 204
  • 249
3

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

vks
  • 65,133
  • 10
  • 87
  • 119
Jasen
  • 11,087
  • 2
  • 27
  • 46
2

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

Guillaume S
  • 1,292
  • 2
  • 17
  • 29