Question

Regular expression - only numbers and the letter "c" before...

  • 4 October 2023
  • 3 replies
  • 184 views

Userlevel 4
Badge +14

I need some help with regular expressions on Nintex Forms for Office 365 for a SharePoint Online list, not a library. 

Criteria for the list text field that is read only. We will make users rename file in library. This field is pulling the name from the associated file in the library.

 

  • Can only start with numbers or “CUI “. This includes the space on CUI label.
  • I got things where I need for the “starts with” using two variable and it will double check if this field starts with “CUI “ if the letter “c” or “C” is in the text on validation. Now I need to resolve the other issue, it can only have numbers or the letter “c” before the extension on the name.  

 

Examples of file names that are acceptable:

  • 2020-1.pdf
  • 2022-150.docx
  • CUI 2023-12.xlsx

My current pattern and combination with my variables and validation rules work fine. However, if I enter CUI a2023-12.pdf in text field the system allows it. I need to only allow “CUI “ (with the space) and numbers only before the “.pdf” in the text field. 

 

 


3 replies

Userlevel 6
Badge +22

Hi @brandiwoodson,

^[cC]|^\d{4}
Will check if the text either starts with a c or C OR starts with 4 digits.
Does that help?

Userlevel 4
Badge +14

I need to prohibit letters all together before the extension at the end which will vary. 

 

If letters are used at all it has to only be to start the name and has to be CUI with a space after it. The rules i created covers that so the C i used to start or numbers worked well. Its just everything else. If someone accidentally puts a letter anywhere else it'll take if those start with conditions are still met and i dont want that.

Userlevel 5
Badge +13

Hi @brandiwoodson 

 

Try using ^(CUI\s\d+|\d+)-\d+\.\w+$

It should match any files beginning with CUI or not and allow for numbers after including hyphens and spaces etc, it also matches to ensure file extensions are used. 
 

 

Reply