In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the php regular how to replace the newline character, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Php regular replacement of line breaks method: 1, create a PHP example file; 2, through the "preg_replace ('/ / s stop stop characters,'', $str);" way to replace line characters.
This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer
How do php regularities replace newline characters?
Use regular substitution
The code is as follows:
$str = preg_replace ('/ / sprinter Universe,'', $str)
Related introduction:
Preg_replace-performs a search and replacement of a regular expression
Description
Preg_replace (string | array $pattern, string | array $replacement, string | array $subject, int $limit =-1, int & $count = null): string | array | null
Search for parts of subject that match pattern and replace them with replacement.
Parameters:
Pattern
The pattern to search for. You can make a string or an array of strings.
You can use some PCRE modifiers.
Replacement
The string or array of strings used to replace. If this parameter is a string and pattern is an array, then all patterns are replaced with this string. If both pattern and replacement are arrays, each pattern is replaced with the corresponding element in replacement. If there are fewer elements in replacement than in pattern, the extra pattern is replaced with an empty string.
Replacement can contain backward references\ n or $n, which is syntactically preferred. Each such reference is replaced by the text captured by the nth capture subgroup to which it is matched. N can be 0-99, and\ 0 and $0 represent the complete pattern matching text. The sequence number of the capture subgroup is counted as follows: the left parenthesis representing the capture subgroup is counted from left to right, starting with 1. If you want to use backslashes in replacement, you must use four ("\", translation note: because this is the first string of PHP, after escape, it is two, and then after the regular expression engine is considered to be an original backslash).
When working in replacement mode and the backward reference needs to be followed by another number (for example, adding an original number immediately after a matching pattern), the syntax\ 1 cannot be used to describe the backward reference. For example,\ 11 will make it impossible for preg_replace () to understand whether you want a\ 1 backward reference followed by an original text 1 or a\ 11 backward reference followed by nothing. The solution in this case is to use ${1} 1. This creates a separate $1 backward reference, a separate original text 1.
When the deprecated e modifier is used, this function escapes some characters (that is,', ",\, and NULL) and then performs backward reference substitution. When this is done, make sure that there are no syntax errors caused by single or double quotes (for example: 'strlen (\' $1\') + strlen ('$2)') after backward quote parsing. Make sure that it conforms to PHP's string syntax and conforms to eval syntax. Because after the replacement is completed, the engine evaluates the resulting string as PHP code using eval and returns the value as the string that ultimately participates in the replacement.
Subject
The string or array of strings to search for and replace.
If subject is an array, the search and replacement will take place on each element of subject, and the return value will also be an array.
Limit
The maximum number of times each mode is replaced on each subject. The default is-1 (infinite).
Count
If specified, it will be populated with the number of completed replacements.
Thank you for reading this article carefully. I hope the article "how to change line characters for php rules" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.