Regex Pattern which Only allow 4 digit

Radhe
Tera Expert

Hi All.

@Mark Roethof 

I have one variable  (Type - single line text) and I need Regex Pattern which allow only 4 digit (number) in this field

 

1 ACCEPTED SOLUTION

Willem
Giga Sage
Giga Sage

To match exactly 4 digits:

/^\d{4}$/
^\d{4}$

 

Not more then 4:

/^\d{0,4}$/
^\d{0,4}$

View solution in original post

7 REPLIES 7

Community Alums
Not applicable

Hello @Radhe,

Please use the below regex

 

  • /^SW\d{4}$/

 

Thanks,

Prasad

sparkles
Tera Contributor

need help in creating a regex validation to accept number from 300 to 500 on service catalog variable.

 

Thanks

Community Alums
Not applicable

Hello @sparkles 

Good Morning,

 

You can use below regex to validate numbers from 300 to 500 on service catalog variable.

  • /^[3-4][0-9][0-9]$|^500$/

Note: You can use 'if loop' to validate the same.

If this helped you in any way, please hit the like button/mark it helpful. So it will help others to get the correct solution.

 

Regards,

Prasad