Formating Help

Hi,

I was wondering if anyone has come across a regex that would format a
full name. It would make sure that there is a space present between two
or more words, only contain letters, hyphens, or a period.

If anyone even only knows a good place to search that would be a great
help.

Shawn S. wrote:

Hi,

I was wondering if anyone has come across a regex that would format a
full name. It would make sure that there is a space present between two
or more words, only contain letters, hyphens, or a period.

You mean match, not “format”, right?

You’re probably looking for something like this:

/(?:[a-zA-Z-.]+(?: |$)){1,}/

This would match a name composed of 2 or more space-seperated words, as
per your request. If you want to limit it to match, say, only up to 3
words, use this slight variation:

/(?:[a-zA-Z-.]+(?: |$)){1,3}/

If anyone even only knows a good place to search that would be a great
help.

Hope that helps,
-Alder

www.regexplib.com

Everything you need.