Search code examples
javascriptxpagesxpages-ssjs

How to put xpages Regex (First Character and last character) cannot be special character


currently i only allow can let the field do not allow special character by using this regex : ^[a-zA-Z0-9_ ]*$

If i just want dont let user to pass for first and last character, what should i put on regex?

sample like :

.Apple = fail

Appplepie. = fail

Apple.Pie = pass


Solution

  • The following regex should work:

    ^[a-zA-Z][a-zA-Z0-9._]*[a-zA-Z]$