There are some special characters in Regular Expressions.Within a pattern,all characters except .,|,(,),[,],{,},+,\,^,$,*,and ? match themselves.They are the special characters.If you know their meaning in the Regular Expressions you can know why are they special.If you want to use themselves in patterns,you need add '\' before them.The following are the meaning of them:
- '.':represents any character except a newline
- '|':Its meaning is 'or'
- '(' and ')':
- '[' and ']':A character class is a set of characters between brackets:[characters] matches any single character between the brackets.
- '{' and '}':
- '+':follow a character or a () expression to express the character or expression must contains more than one times.
- '\':
- '^':a anchor.match the begining of a line
- '$':a anchor.match the end of a line or ...
- '*':
- '?':
Copy the list of these from <the ruby way>:
-
^ Beginning of a line or string
-
$ End of a line or string
-
. Any character except newline (unless POSIX)
-
\w Word character (digit, letter, or underscore)
-
\W Non-word character
-
\s Whitespace character (space, tab, newline, and so on)
-
\S Non-whitespace character
-
\d Digit (same as [0-9])
-
\D Non-digit
-
\A Beginning of a string
-
\Z End of a string or before newline at the end
-
\z End of a string
-
\b Word boundary (outside [ ] only)
-
\B Non-word boundary
-
\b Backspace (inside [ ] only)
-
[ ] Any single character of set
-
* Zero or more of the previous subexpression
-
*? Zero or more of the previous subexpression (non-greedy)
-
+ One or more of the previous subexpression
-
+? One or more of the previous subexpression (non-greedy)
-
{m,n} M to n instances of the previous subexpression
-
{m,n}? M to n instances of the previous subexpression (non-greedy)
-
? Zero or one instance of the previous regular expression
-
| Alternatives
-
( ) Grouping of subexpressions
-
(?# )
分享到:
相关推荐
"Chapter5: Special characters, module contents and Regular Expression Objects"涉及了正则表达式中的特殊字符、模块内容和正则表达式对象。这个部分解释了特殊字符在正则表达式中的作用,如何使用正则表达式对象...
7. Special Characters (特别字符) 正则中存在一些特别字符,它们不会根据字面意思进行匹配,而有特别的意义。例如:^、$、|、() 等。 8. 实践应用 正则表达式可以用于匹配手机号码、电子邮件地址、手机号码、...
If you've ever found yourself pulling your hair out trying to build the perfect regular expression to match the least amoun... Remove blank lines A question we often see is "I have a lot of blank ...
A.1 Special Characters in Regular Expressions A.2 Searching for Special Characters A.3 Using the Period A.4 Using Brackets A.4.1 Using the Dash within Brackets A.4.2 Using the Caret within Brackets A....
Operators And Special Methods Builtins Build and C API Changes Performance Porting To Python 3.0 What’s New in Python 2.7 The Future for Python 2.x Changes to the Handling of Deprecation ...
traits)、类模板basic_regex(Class template basic_regex)、类模板sub_match(Class template sub_match)、类模板match_results(Class template match_results)、正则表达式算法(Regular expression ...
About_regular_expression.help.txt About_reserved_words.help.txt About_scope.help.txt About_script_block.help.txt About_shell_variable.help.txt About_signing.help.txt About_special_characters.help.txt ...
在Ruby编程语言中,正则表达式(Regular Expression)是一种强大的文本处理工具,被广泛应用于字符串搜索与替换、数据验证以及模式匹配等场景。本篇文章将深入探讨Ruby中常用的正则表达式规则及其应用场景,帮助读者...
- **正则表达式(Regular Expression)**:探讨Shell脚本中正则表达式的使用方法。 - **理论(Theory)**:讲解正则表达式的基本概念和匹配规则。 - **元字符(Meta Character)**:介绍Shell正则表达式中的元字符及其作用...
Contents Contents ii List of Tables x List of Figures xiv 1 Scope 1 2 Normative references 2 3 Terms and definitions 3 4 General principles 7 4.1 Implementation compliance . ....4.2 Structure of this ...
* Summary of regular-expression constructs 正则表达式结构简介: * Construct Matches * Characters 字符: * x The character x x 字符 x * \\ The ...