Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for no space at start or end, but allow space in middle but also allow only one char inputs

Tags:

javascript

php

My RegExp is

/^[A-Za-z ]*$/

Then what should i write to not allow space at start or end, but allow space in middle

like image 438
user3359065 Avatar asked Dec 01 '25 01:12

user3359065


1 Answers

This regular expression will match any strings that conform to your original expression that do not have a space at the beginning or end

^(?! )[A-Za-z ]*(?<! )$
like image 115
Tom Griffin Avatar answered Dec 03 '25 13:12

Tom Griffin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!