php - preg_match dot and slash

314

I would like to add a regular expression character dot. and such a slash/.

    'numericString' => array(
        'pattern' => '^[a-zćęłńóśźżA-Z0-9\s]+$',
    )

How i can do?

743

Answer

Solution:

add\. and\/

'numericString' => array(
    'pattern' => '^[a-zćęłńóśźżA-Z0-9\s\.\/]+$',
)
112

Answer

Solution:

Note: you must escape the characters "^.[$()|*+?{\" with a backslash ('\'), as they have special meaning.

Use the below code..

'numericString' => array(
'pattern' => '^[a-zćęłńóśźżA-Z0-9\s\.\/]+$',
 )
816

Answer

Solution:

A literal. is expressed in a regex as\.

A literal/ is expressed as\/

Note: not all regex flavours require escaping the/, only the ones that use it for delimiting the regex.

People are also looking for solutions to the problem: php - Manage the errors of a framework

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.