What would the regex be in PHP to make sure a phrase is a Google Publisher code and not anything else? Like... "pub-1234567890123456"
I want the Regex to make sure the inputted text is a Google Publisher Code and not some random numbers or letters or something.
There is no know way to check if a publishers ID is valid or not, so I suggest you use a numbers only (16) validation check on your input, thus use the text pub- within your scripts, as above though, this could still be a random 16digit number, theres no way to check that its a valid publishers id, only to manually try it.
Here you go, I created alittle function for you: The regex: #^pub-[0-9]{16}$# <?php function google_pub($pub) { $validate = preg_replace('#^pub-[0-9]{16}$#', "", $pub); if(empty($validate)) { return true; } else { return false; } } //1 = valid, 0 = not valid echo(google_pub("pub-1234567890123455")); ?> PHP: