Regular expression for alphanumeric and dot

Hi I have a variable in the Silex route and we only allow alphanumeric values

->assert('hash','\w+')

I would also like to resolve the point in the variable, but my efforts to edit this regular expression have failed. Help with thanks, thanks!

+3
source share
3 answers

Try using class ( […]), for example:

[\w.]+

For instance:

->assert('hash','[\w.]+')
+6
source

Try

->assert('hash', '[a-zA-Z0-9.]+')

Why not [\w.]?

You marked your question as PHP, so I assume this guide applies. And there he reads

\w  
    any "word" character

and

"" , , "Perl". PCRE , . , "fr" () , , 128, \w.

\w äöüß... .

,

->assert('hash', '[a-fA-F0-9.]+')

., G Z ...

+7

assert(), char:

->assert('hash','[\w.]+')
+2

All Articles