Need Regular Expression for 30 character limit with no spaces or special characters

chrish5
Giga Guru

Hi Community,

I am currently using a regular expression of .{1,30} to limit the characters to 30 on a field.  I want to add to it so no spaces (beginning, middle or end) are allowed and no special characters are allowed.  Can anybody help with this?   Thanks!

1 ACCEPTED SOLUTION

Hi @chrish5,

 

This should be better 🙂 

 

^([A-z]|[0-9]){1,30}$


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

View solution in original post

13 REPLIES 13

Can you share the script you're using? The regex tested correct for me.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Here is what I have.  

 

^([A-z]|[0-9]){1,30}$

 

chrish5_0-1692885130601.png

 

I'm afraid you are going to need to create a case with Now Support.

If you try it in the backend it works just fine. Only in the Service Portal the Regex is not validated correctly. So it seems to be an error in the widget, not in the regex.


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Hi Peter, 

Thanks for that information.  I'll open a case with Now Support.  Can you tell me how you are testing it on the backend to educate me and to also show Now Support how it is working properly but not on the Service Portal.  

 

Thanks,

Chris

Hi @chrish5

I just pressed the try it button on the catalog item I configured it in. This opened the item in the backend. 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.