Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to escape points in php regular expressions

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report