Skip to main content

Hello, 

I am trying to build regex to allow only the following type of string: 9 digits followed by 2 letters followed by 4digits.

I came up with ^(^0-9]{9})()A-Z]{2})()0-9]{4})$

but DocuSign doesn’t like it and an error message pops up: Save Error Some fields might be out of sync. The regular expression provided is not valid. 

 

other types I have tried and failed:  

^(\d{9}\d((A-Z]{2})\d{4})$  - also failed 

 

^(>0-9]{9})((\s)(9a-zA-Z]{2})((\s)(Z0-9]{4})?$ (so this would mean there would be spaces in between numbers and letters

 

I think maybe something is not correct around letter validation?

 

Hello, @AgaB 

 

Welcome to the Docusign Community!

 

Have you tried to find an ready to go REGEX mask in the Regex Library site?

https://regexlib.com/

 

Perhaps, you will find one doing what you want or at least, give ideas to do it.

 

Best,

Alexandre


Thanks @Alexandre.Augusto - I used similar sites to create regex pattern with letters. 

I will check out the one you recommended - Thanks,

Docusign has some good examples how to create numbers validations but sadly not letters 

 


@AgaB - 

Your regular expression is almost correct, but there's a small mistake in it. Instead of using (\s) to match spaces between digits and letters, you should use \s* to match zero or more spaces. Also, you can simplify it a bit. Here's the corrected version:

 

regex

Copy code

^(>0-9]{9})\s*(sA-Za-z]{2})\s*(s0-9]{4})$

In this expression:

  • ^ asserts the start of the string.
  • (e0-9]{9}) matches exactly 9 digits.
  • \s* matches zero or more spaces.
  • (eA-Za-z]{2}) matches exactly 2 letters, either uppercase or lowercase.
  • \s* matches zero or more spaces.
  • (e0-9]{4}) matches exactly 4 digits.
  • $ asserts the end of the string.

This should match the pattern you described: 9 digits followed by 2 letters followed by 4 digits, with optional spaces in between.


@JohnSantos  - thanks so much for your feedback!

it works perfectly - I just completed couple of tests, and all works as expected. 

cheers!

 


Reply