Welcome to WebmasterWorld Guest from 184.72.177.182

Forum Moderators: open

Message Too Old, No Replies

Regular expression to allow space, disallow tab, ff, lf

\s is too inclusive

     
3:45 pm on Jan 19, 2007 (gmt 0)

New User

10+ Year Member

joined:June 11, 2005
posts:18
votes: 0


What is the regular expression that matches a space, but does not match "other whitespace characters" (tab, form feed, and line feed)

I want a regular expression to match a-z, A-Z, 0-9, and space. For this particular situation, I do not want users to be allowed to input a tab character, or line feed, or form feed.

I know the following regular expression will do everything except the space requirement:

var alphaRE = /^[a-zA-Z0-9]+$/;

How do I change that regular expression to include just space characters?

TIA,

Dennis

3:47 pm on Jan 19, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member fotiman is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Oct 17, 2005
posts:4965
votes: 10


var alphaRE = /^[a-zA-Z0-9 ]+$/;

Note, just add a space within the brackets.

4:24 pm on Jan 19, 2007 (gmt 0)

New User

10+ Year Member

joined:June 11, 2005
posts:18
votes: 0


Yikes, Fotiman! I had a feeling it was something simple. Thank you very much!

Dennis

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members