[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to do a regex that allow only: numbers, alphabetic, spaces and comma(,) for javascript?

Posted on 2009-02-12
5
Medium Priority
?
878 Views
Last Modified: 2012-05-06
How to do a regex that allow only: numbers, alphabetic, spaces and comma(,) for javascript?
0
Comment
Question by:MrFahad
  • 3
  • 2
5 Comments
 
LVL 27

Accepted Solution

by:
ddrudik earned 100 total points
ID: 23623343
1 or more times:
/^[\da-z ,]+$/i
0 or more times:
/^[\da-z ,]*$/ig;
0
 

Author Comment

by:MrFahad
ID: 23623369
hmm what you mean by 1 or more times and 0 or more times thank you :)
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 23623380
Do you want to allow empty input?  If so, use the 0 pattern, if not, use the 1 pattern.
0
 

Author Closing Comment

by:MrFahad
ID: 31546127
very fast reply less than 1min i swear i almost thought that this an auto reply lol :p
great job
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 23627763
Thanks for the question and the points.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question