Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

regex problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

regex problem

Postby faust » Sat Jun 08, 2013 12:37 am

Hey guys, I really really suck at regex but I need one asap. The rules are:
- can contain only alphanum chars and underscore;
- must begin and end with a letter (not underscore or number);
- no spaces;

I need this to validate a field. Thanks, cheers ^_^
faust
New php-forum User
New php-forum User
 
Posts: 109
Joined: Thu May 03, 2012 7:22 am

Re: regex problem

Postby paintitblack » Mon Feb 17, 2014 9:26 pm

This should do it:

Code: Select all
^[a-zA-Z][a-zA-Z0-9_]*[a-zA-Z]$


Note that this requires your data field to be at least two characters long.
paintitblack
New php-forum User
New php-forum User
 
Posts: 8
Joined: Mon Feb 17, 2014 8:53 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.