Jump to content

Recommended Posts

Hey Guys ... never used regex and don't really get it (yet fingers crossed) but i need to check a string meets a length and prefix expression.

 

i need the string to match:

 

"SNPLXXXXX" where the "X"'s are integers and "SNPL" is the manditory prefix

 

what i know is (is not much):

 

if (eregi("", $_POST['barCode'])){

Link to comment
https://forums.phpfreaks.com/topic/131354-solved-regex-request/
Share on other sites

Sasa, when you need 5 digits, you don't need to state an equal minimum and a maximum.. simply use {5}.

 

To the OP, try to learn preg (part of Perl Compatible Regular Expressions) instead of ereg. As of PHP6, POSIX (which ereg is part of) will not be supported within the PHP6 core by default. I believe it will only be available as an extension.

 

There are resources here at PHPFreaks to help you out with that.

 

Cheers,

 

NRG

Link to comment
https://forums.phpfreaks.com/topic/131354-solved-regex-request/#findComment-682171
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.