regex code for text entry | Experience Community
Skip to main content
Solved

regex code for text entry

  • Apr 11, 2024 2:53 AM UTC
  • 2 replies
  • 172 views

Forum|alt.badge.img+1

i have text entry field for user to input medical diagnosis. how can i restrict user to enter only alphabets, numbers, and a few other punctuation marks eg comma, fullstop, dash, apostrophe?

ultimate plan is to prevent users from entering something like a smiley etc.

thanks!

Best answer by omkarkewat

 hi @sics_sue_choo The below regex will allow strings that contain only alphabets, numbers, commas, full stops, apostrophes, spaces, and dashes. It will reject strings that contain any other characters, such as smileys or special symbols. You will need to add the characters, symbols in the below regex code that can be allowed in the open text box.

^[a-zA-Z0-9,.'\s-]+$

View original

2 replies

Forum|alt.badge.img+23
  • QPN Level 5 ●●●●●
  • Answer
  • Apr 11, 2024 9:11 AM UTC

 hi @sics_sue_choo The below regex will allow strings that contain only alphabets, numbers, commas, full stops, apostrophes, spaces, and dashes. It will reject strings that contain any other characters, such as smileys or special symbols. You will need to add the characters, symbols in the below regex code that can be allowed in the open text box.

^[a-zA-Z0-9,.'\s-]+$


Forum|alt.badge.img+1
  • Author
  • Level 2 ●●
  • Apr 12, 2024 6:52 AM UTC

thanks!!