Get the App
SLTechnology News&Howtos  ›  Development  › 

How to escape points in php regular expressions

Shulou Source: shulou.com Published: 2022-06-01 13:13:16 09月11日 Update

This article mainly introduces the relevant knowledge of "how to escape the midpoint of php regular expression". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to escape the midpoint of php regular expression" can help you solve the problem.

In PHP, you can escape points using the "preg_quote ()" function, which is used to escape regular expression characters by adding a backslash to the characters in the regular expression syntax with the syntax "preg_quote ('.','/')".

This article operating environment: Windows10 system, PHP7.1 version, Dell G3 computer.

How to escape a point in a php regular expression

The preg_quote function is used to escape regular expression characters.

Grammar

String preg_quote (string $str [, string $delimiter = NULL])

Preg_quote () takes the parameter str and adds a backslash to each of the characters in the regular expression syntax. This is usually used when you have some runtime strings that need to be matched as regular expressions.

The special characters of regular expressions are:. \ + *? [^] $() {} =

< >

|:-

Parameter description:

$str: enter a string.

$delimiter: if the optional parameter delimiter is specified, it will also be escaped. This is typically used to escape the delimiter used by the PCRE function. / is the most common delimiter.

Return value

Returns the escaped string.

Examples are as follows:

Output result:

That's all for "how to escape points in php regular expressions". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Tags: Regular expression escape character midpoint function grammar parameter string knowledge delimiter slash industry different practical special content practical practical article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple OPPO Reno macOS MySQL