Validate Google Site Verification URLs with Regex

2

With $ _SERVER ['REQUEST_URI'] I have captured the following address below!

/google9f7804416f93fdd6b.html

I need to perform a validation with ER, the function must recognize the word Google parâmetros randômicos 9f7804416f93fdd6b and the .html extension, so that we can manually call the GoogleController .

I have tried here with some examples, but always false.

    
asked by anonymous 30.08.2015 / 02:18

1 answer

4

Well, I think this regex works for what you want:

[Gg]oogle[a-z0-9]*.html

will detect google or google, any character for the random values and then the html extension. If you want to detect other extensions you can do:

[Gg]oogle[a-z0-9]*.[a-z]

To get the values of what the regex has picked up, just put () around what you want to get. For example to get random values fazes:

[Gg]oogle([a-z0-9]*).[a-z]
    
30.08.2015 / 03:35