I need to create a regular expression that allows for a combination of letters, numbers, and spaces within a word, ranging in length from 3 to 50 characters, but without spaces at the beginning or end of the string. Here is the regex pattern I have come up with:
/^[^-\s]([a-z0-9]|[a-z0-9\s-]){3,50}[^-\s]+$/i
Examples of valid strings:
uma
umair
umair K
Examples of invalid strings:
uma
u
um
umair
The last example contains a trailing space, making it invalid.