Basic regex PHP issue
I am trying to grab the articleId which is formatted as follows:
开发者_如何学JAVA articleId=1234567
Here is the code I am using
$regex = 'articleId\=[0-9]{7}';
preg_match_all($regex,$data,$match);
for ($i=0; $i< count($match[0]); $i++) {
echo "".$match[1][$i]."]";
}
I am receiving the following error: preg_match_all() [function.preg-match-all]: Delimiter must not be alphanumeric or backslash
FWIW I am using 5.2.17
place delimiters in your regexp, like this:
$regex = '/articleId=[0-9]{7}/';
also, there is no need to escape equal sign
You forgot your '/'
preg_match_all('/' . $regex . '/',$data,$match);
or alternatively
$regex = '/articleId\=[0-9]{7}/';
精彩评论