progwihz@yahoo.com Posted January 3, 2008 Share Posted January 3, 2008 Hi all, am trying to implement some regex functions for data validation. As it’s quite confusing (for me at least) I’ve decided to layout what I am trying to achieve below. I’ve got several senarios that I am trying to generate regex to accomplish. 1. validate string data (allow alpha num _- +) no spaces allowed 2. validate string data (allow alpha, num _ - + &) no spaces allowed 3. validate string data (allow num only with max length of 2) no spaces allowed 4 validate data (allow num only) any length many thanks Quote Link to comment Share on other sites More sharing options...
effigy Posted January 3, 2008 Share Posted January 3, 2008 3 and 4 can match nothing at all: 1. /\A[-+\w]\z/ 2. /\A[-+&\w]\z/ 3. /\A\d{,2}\z/ 4. /\A\d*\z/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.