regex - Regular expression to allow single whitespace between words -


i know regular expression allow whitespace. example item name(2 words). can made of uppercase, lowercase letters , 1 whitespace. i.e word1 word2. tried [a-za-z\sa-za-z] doesn't work.

try this:

[a-za-z]+(\s[a-za-z]+)? 

this allows 1 word, optionally followed single whitespace , word, requires whitespace character between 2 words, if present @ (ie regex allows single word).


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -