try the following:
^(\s?\.?[a-zA-Z]+)+$
EDIT1
/^(\s{0,1}\.{0,1}[a-zA-Z]+)+$/.test('space ..hello space') false /^(\s{0,1}\.{0,1}[a-zA-Z]+)+$/.test('space .hello space') true
v2:
/^(\s?\.?[a-zA-Z]+)+$/.test('space .hello space') true /^(\s?\.?[a-zA-Z]+)+$/.test('space ..hello space') false
v3: if you need some kind of it, like one space or a point between
/^([\s\.]?[a-zA-Z]+)+$/.test('space hello space') true /^([\s\.]?[a-zA-Z]+)+$/.test('space.hello space') true /^([\s\.]?[a-zA-Z]+)+$/.test('space .hello space') false
v4:
/^([ \.]?[a-zA-Z]+)+$/.test('space hello space') true /^([ \.]?[a-zA-Z]+)+$/.test('space.hello space') true /^([ \.]?[a-zA-Z]+)+$/.test('space .hello space') false /^([ ]?\.?[a-zA-Z]+)+$/.test('space .hello space') true
EDIT2 Explanation:
can be a problem in \ s = [\ r \ n \ t \ f] therefore, if only the space - \s? allowed \s? can be replaced by [ ]?
http://regex101.com/r/wV4yY5
source share