[email protected] 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 Link to comment https://forums.phpfreaks.com/topic/84304-regular-expressions-to-validate-data/ 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/ Link to comment https://forums.phpfreaks.com/topic/84304-regular-expressions-to-validate-data/#findComment-429329 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.