Jump to content

regex


alohatofu

Recommended Posts

probably because you have the . in there, meaning there has to be an extra character...

 

2007 042000834420 would work

2007z042000834420 would work

2007=042000834420 would work...

 

try /^2007[0-9]{12}/

 

that'd match

 

2007042000834420

 

but make sure you also want it to match

 

200704200083442020394u2on3 oi432h89op4 2h843ho

 

-- because it will

Link to comment
https://forums.phpfreaks.com/topic/48000-regex/#findComment-234578
Share on other sites

That still didn't output the right number

 

here's what I have

 //matches ac ticket number
$acticketpattern = '/^2007[0-9]{12}/';
if (preg_match("$acticketdpattern", "Refer to ticket number: 2007042000834420You can", $matches_acticket)) {
echo "Match was found <br />";
echo $matches_acticket[0];
}

 

Link to comment
https://forums.phpfreaks.com/topic/48000-regex/#findComment-234579
Share on other sites

Guest prozente

^ means match from the beginning of the string, so you'll want to remove it in this case. You also have a D in the variable name you're passing to preg_match.

 

<?php
$acticketpattern = '/2007[0-9]{12}/';
if (preg_match($acticketpattern, "Refer to ticket number: 2007042000834420You can", $matches_acticket)) {
  echo "Match was found <br />";
  echo $matches_acticket[0];

}

Link to comment
https://forums.phpfreaks.com/topic/48000-regex/#findComment-234583
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.