Skip to main content
Inspiring
August 20, 2021
Answered

RegEx for more than one arbitrary mask format

  • August 20, 2021
  • 1 reply
  • 687 views

I've heard that RedEx script is needed to accomodate more than one arbitrary mask format in a field. How might I be able to allow for the two formats in one field as follows?:

 

Format 1: OOOOOOOOOOO (11 characters)

Format 2: OOOOOOOOOO (10 characters)

 

Thank you in advance!

This topic has been closed for replies.
Correct answer dpoag

Thank you. I was given the below validation script and it worked!

 

var str = event.value;
var reg = /^[a-zA-Z]{1,2}[0-9]{9}$/;
var r = reg.test(str);
if(!r)
app.alert("Your message goes here",3);

1 reply

try67
Community Expert
Community Expert
August 20, 2021

What does "O" stand for? Any character whatsoever?

And do you want it to only accept a value that's 10 or 11 characters long?

If so, you need a validation script, not a format script.

dpoagAuthorCorrect answer
Inspiring
August 21, 2021

Thank you. I was given the below validation script and it worked!

 

var str = event.value;
var reg = /^[a-zA-Z]{1,2}[0-9]{9}$/;
var r = reg.test(str);
if(!r)
app.alert("Your message goes here",3);