Jump to content

[SOLVED] REGEX Request


n3ightjay

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.