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

Help with preg_match

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Help with preg_match

Postby Lightning » Sat Nov 24, 2012 3:11 am

Hi..

I am trying to trying to create the following patterns:

1. To accept "2 digits" followed by "-" then "5 digits" (ex: 04-35415)

2. To accept at least "15 character"s followed by "comma" then followed by "maximum 34 characters".

3. To accept "integers only" and "not more 3 digits" (ex: 555).

Thank you...
Lightning
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Nov 24, 2012 2:57 am

Re: Help with preg_match

Postby seandisanti » Tue Nov 27, 2012 9:03 am

It looks more like you're trying to have someone else create the patterns. If you show a reasonable attempt i'm sure someone would be happy to correct whatever you're doing wrong.
seandisanti
php-forum Fan User
php-forum Fan User
 
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: Help with preg_match

Postby Lightning » Tue Nov 27, 2012 1:21 pm

oh really! Thanks for reply any way..

I have solved number three but not with preg_match..

and i tried to solve number 1 using this pattern but it's wrong

if(!preg_match("/^([0-9]){0,2}\-{0,1}([0-9]){0,5}$/",$code))echo "False"; else echo "True";


And number 2:

if(!preg_match("/^[0-9a-zA-z]{0,15}\,{0,1}([0-9a-zA-z]){0,34}$/"))echo "False";else echo "True";



so if it happen to know where I am mistaken please be kind to reply.. Thanks
Lightning
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Nov 24, 2012 2:57 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

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