jasmine825 jasmine825 - 2 months ago 15
PHP Question

Wildcard in an if statement with a variable as a count

if ($acc_number=='___001*') {

//add to $number


I want to put this in a preg_match but I'm not sure how I can do this. I want there to be 3 digits before 001 then infinite after. Then after to add there information to a variable called $number.


I think you want to do something like this:

if (preg_match("/^([0-9]{3})001([0-9]{0,})$/", $acc_number)) {
    // Add to $number

I'm not a regular expression expert, so I'm no sure if there is better (shorter) pattern for this.