homepage Welcome to WebmasterWorld Guest from 54.198.25.229
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Regular expression to allow space, disallow tab, ff, lf
\s is too inclusive
dtleahy

5+ Year Member



 
Msg#: 3224980 posted 3:45 pm on Jan 19, 2007 (gmt 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

 

Fotiman

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3224980 posted 3:47 pm on Jan 19, 2007 (gmt 0)

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

Note, just add a space within the brackets.

dtleahy

5+ Year Member



 
Msg#: 3224980 posted 4:24 pm on Jan 19, 2007 (gmt 0)

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

Dennis

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved