


Non-printing characters
Character Meaning
\cx Matches the control character specified by x. For example, \cM matches a Control-M or carriage return character. The value of x must be one of A-Z or a-z. Otherwise, c is treated as a literal 'c' character.
\f Matches a form feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\r Matches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any whitespace characters, including spaces, tabs, form feeds, etc. Equivalent to [ \f\n\r\t\v].
\S Matches any non-whitespace characters. Equivalent to [^ \f\n\r\t\v].
\t Matches a tab character. Equivalent to \x09 and \cI.
\v Matches a vertical tab character. Equivalent to \x0b and \cK.
Special characters
The so-called special characters are characters with special meanings, such as the * in "*.txt" mentioned above. Simply put, it means The meaning of any string. If you want to find files with * in the file name, you need to escape the *, that is, add a \ before it. ls\*.txt. Regular expressions have the following special characters.
Special characters Description
$ Match the end of the input string. If the RegExp object's Multiline property is set, $ also matches '\n' or '\r'. To match the $ character itself, use \$.
( ) Marks the beginning and end of a subexpression. Subexpressions can be obtained for later use. To match these characters, use \( and \).
* Matches the preceding subexpression zero or more times. To match * characters, use \*.
+ Match the previous subexpression one or more times. To match the + character, use \+.
. Matches any single character except the newline character \n. To match ., use \.
[ Marks the beginning of a square bracket expression. To match [, use \[.
? Matches the preceding subexpression zero or one time, or specifies a non-greedy qualifier. To match the ? character, use \?.
\ Mark the next character as either a special character, a literal character, a backward reference, or an octal escape character. For example, ‘n’ matches the character ‘n’. '\n' matches newline character. The sequence '\\' matches "\", while '\(' matches "(".
^ Matches the beginning of the input string, unless used in a square bracket expression, in which case it means not Accepts this set of characters. To match the ^ character itself, use \^ . To match |, use \|. Regular expressions are constructed in the same way as mathematical expressions, using various metacharacters and operators. Expressions can be combined together to create larger expressions. The components of a regular expression can be a single character, a collection of characters, a range of characters, a selection between characters, or any combination of all of these components. Qualifier
The qualifier is used to specify how many times a given component of the regular expression must appear to satisfy the match. There are * or + or ? or {n} or {n,} or {. n, m} 6 types in total The *, + and ? qualifiers are all greedy, because they will match as many words as possible. Non-greedy can be achieved by adding a ? after them. Or minimum match. Regular expression qualifiers are:Characters Description
to Matches "z" and "zoo". * Equivalent to {0,}. , but cannot match "z". + is equivalent to {1,}.
? Matches the preceding subexpression zero or one time. For example, "do(es)?" would match "do" in "do" or "does". ? Equivalent to {0,1}.
{n} n is a non-negative integer. Match a certain number of n times. For example, 'o{2}' cannot match the 'o' in "Bob", but it can match two o's in "food".
{n,} n is a non-negative integer. Match at least n times. For example, 'o{2,}' does not match the 'o' in "Bob", but it does match all o's in "foooood". ‘o{1,}’ is equivalent to ‘o+’. 'o{0,}' is equivalent to 'o*'.
{n,m} m and n are both non-negative integers, where n
The above is the detailed content of Example usage of non-printing characters, special characters, and qualifiers (regular expression character set 2). For more information, please follow other related articles on the PHP Chinese website!

两种去除方法:1、利用preg_replace()执行正则表达式搜索所有大写字母并将其替换为空字符即可,语法“preg_replace('/[A-Z]/','',$str)”。2、利用preg_filter()执行正则表达式搜索所有大写字母并将其替换为空字符即可,语法“preg_filter('/[A-Z]/','',$str)”。

方法:1、用“str_replace(" ","其他字符",$str)”语句,可将nbsp符替换为其他字符;2、用“preg_replace("/(\s|\ \;||\xc2\xa0)/","其他字符",$str)”语句。

随着数据量的不断增大,正则表达式匹配成为了程序中常用的操作之一。而在Go语言中,由于其天然的并行ism,以及与底层系统的交互性和高效性,使得Go语言的正则表达式匹配极具优势。那么如何使用Go语言编写高性能的正则表达式匹配呢?一、了解正则表达式在使用正则表达式前,我们首先需要了解正则表达式,了解其基本语法规则以及常用的匹配字符,使我们能够在编写正则表达式时更加

两种方法:1、用preg_replace(),可执行正则表达式的搜索和替换,只需将字符串中匹配的字符替换为空字符即可,语法“preg_replace(正则, "", $str)”。2、用preg_match_all(),可搜索字符串中所有和正则表达式匹配的结果,会将每次的匹配结果放在一个数组$array中,语法“preg_match_all(正则,$str,$array);”。

php中可用preg_match_all()配合正则表达式过滤字符串,只获取中文字符;语法“preg_match_all("/[\x{4e00}-\x{9fff}]+/u","$str",$arr);”,会将匹配字符存入“$arr”数组中。

在javascript中,可以使用replace()函数配合正则表达式“/[u4e00-u9fa5|,]+/ig”来查找字符串中的所有非汉字字符,并将其替换为其他指定值,语法“字符串对象.replace(/[u4e00-u9fa5|,]+/ig,'指定替换值')”。

Java语言正则表达式的使用方法正则表达式是一种强大的文本处理工具,可以用来匹配和验证文本。在Java语言中,也可以使用正则表达式来实现字符串的匹配和处理。本文将介绍Java语言正则表达式的使用方法,涵盖正则表达式的基础知识,常用的正则表达式语法,以及在Java程序中使用正则表达式的方法。一、基础知识正则表达式是什么?正则表达式是一种文本模式,用来描述一组字

在PHP开发中,正则表达式是非常重要的工具,用于匹配、查找和替换文本中的特定字符串。然而,编写高效的正则表达式并不是一件易事,需要开发者具备一定的技巧和经验。下面是一些可以帮助您编写高效正则表达式的技巧:1.尽可能使用非贪婪匹配默认情况下,正则表达式是贪婪的,即它们将尽可能匹配更多的文本。在某些情况下,可能需要使用非贪婪匹配来避免这种情况。非贪婪匹配使用"


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools