Adnan Zamurred Posted February 28, 2020 Share Posted February 28, 2020 Hi there, I've searched the wiki but couldn't find any example for regex expression. I need the following: 1. Regex validation for maximum of 100 words (Includes numbers and letters) 2. Regex for email address e.g. @hotmail.co.uk Can I get some assistance please? Link to comment Share on other sites More sharing options...
Adnan Zamurred Posted February 28, 2020 Author Share Posted February 28, 2020 Also, is there a way for a user to check how many words they have typed? I am building a form where the user types a passage of maximum 100 words, anything more than that should stop the user to type further. Link to comment Share on other sites More sharing options...
Dan Munns Posted February 28, 2020 Share Posted February 28, 2020 For the word count you could try this: ^(?:\b\w+\b[\n\r\s]*){1,100}$ They may hit the character limit before the word limit though depending on the field used. You could add the text into the validation message "Max word limit reached" and add to the description of the field "Max 100 words" For addresses it is simply (.*@hotmail.com) 1 Link to comment Share on other sites More sharing options...
Adnan Zamurred Posted March 3, 2020 Author Share Posted March 3, 2020 @Dan Munns I just tried the above, it works for 100 words. However, it fails for any special characters such as full stops. Is there a way to add it in? Link to comment Share on other sites More sharing options...
Dan Munns Posted March 3, 2020 Share Posted March 3, 2020 @Adnan Zamurred try this: ^(?:\b\w+\b[\n\r\s\W]*){1,100}$ I missed the \W on the last one to account for special characters. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now