Regular charactersdescribe
\Marks the next character as a special character, or a literal character, or a backreference, or an octal escape character. For example,“n"Match characters"n"。"\n"Matches a newline character. serial"\\"match"\"and"\("then matches"("。
^Matches the beginning of the input string. ^ also matches if the Multiline property of the RegExp object is set“\n"or"\r"position after。
$Matches the end of the input string. If the Multiline property of the RegExp object is set,$ also matches“\n"or"\r"previous location。
*Matches the preceding subexpression zero or more times. For example, zo* matches“z"as well as"zoo"。*Equivalent to{0,}。
+Matches the preceding subexpression one or more times. For example,“zo+"can match"zo"as well as"zoo",but cannot match"z"。+Equivalent to{1,}。
?Matches the preceding subexpression zero or one time. For example,“do(es)?"can match"does"or"does"in"do"。?Equivalent to{0,1}。
{n}nis a non-negative integer. match confirmednSecond-rate。For example,“o{2}"cannot match"Bob"in"o",But it matches"food"two of o。
{n,}nis a non-negative integer。match at leastnorder。For example,“o{2,}"cannot match"Bob"in"o",but can match"foooood"all in o。"o{1,}"Equivalent to"o+"。"o{0,}"is equivalent to"o*"。
{n,m}mandnare all non-negative integers,inn<=m。least matchntimes and matches at mostmorder。For example,“o{1,3}"will match"fooooood"the first three of o。"o{0,1}"Equivalent to"o?"。Please note that there cannot be a space between the comma and the two numbers。
?When this character immediately follows any other qualifier(*,+,?,{n},{n,},{n,m})Later, the matching pattern is non-greedy. Non-greedy mode matches as little of the searched string as possible, while the default greedy mode matches as much of the searched string as possible. For example, for the string“oooo","o+?"will match a single"o",and"o+"will match all"o"。
.match except“\n"any single character other than . To match include"\n"any characters, please use something like"(.|\n)"mode。
(pattern)Match pattern and get this match. The obtained matches can be obtained from the generated Matches collection, using the SubMatches collection in VBScript and using$0…$9property. To match parentheses characters, use“\("or"\)"。
(?:pattern)Matches the pattern but does not obtain the matching result, which means that this is a non-acquisition match and is not stored for later use. This is done using the or character“(|)"This is useful for combining parts of a pattern. For example"industr(?:y|ies)"Just a comparison"industry|industries"A simpler expression。
(?=pattern)Forward positive lookup, matches the search string at the beginning of any string matching pattern. This is a non-fetch match, that is, the match does not need to be fetched for later use. For example,“Windows(?=95|98|NT|2000)"can match"Windows2000"in"Windows",but cannot match"Windows3.1"in"Windows"。Prefetch does not consume characters, that is, after a match occurs, the search for the next match starts immediately after the last match, rather than starting after the character containing the prefetch。
(?!pattern)Forward negative lookup, matches the search string at the beginning of any string that does not match the pattern. This is a non-fetch match, that is, the match does not need to be fetched for later use. For example“Windows(?!95|98|NT|2000)"can match"Windows3.1"in"Windows",but cannot match"Windows2000"in"Windows"。Prefetch does not consume characters, that is, after a match occurs, the search for the next match starts immediately after the last match, rather than starting after the character containing the prefetch
(?<=pattern)Reverse positive pre-checking is similar to forward positive pre-checking, but in the opposite direction. For example,“(?<=95|98|NT|2000)Windows"can match"2000Windows"in"Windows",but cannot match"3.1Windows"in"Windows"。
(?<!pattern)Reverse negative pre-checking is similar to forward negative pre-checking, but in the opposite direction. For example“(?<!95|98|NT|2000)Windows"can match"3.1Windows"in"Windows",but cannot match"2000Windows"in"Windows"。
x|yMatch x or y. For example,“z|food"can match"z"or"food"。"(z|f)ood"then matches"zood"或"food"。
[xyz]Character collection. Matches any one of the characters contained. For example,“[abc]"can match"plain"in"a"。
[^xyz]A collection of negative characters. Matches any character not included. For example,“[^abc]"can match"plain"in"p"。
[a-z]Character range. Matches any character within the specified range. For example,“[a-z]"can match"a"arrive"z"Any lowercase alphabetic character within the range。
[^a-z]Negative character range. Matches any character not within the specified range. For example,“[^a-z]"Can match anything that is not"a"arrive"z"Any character within the range。
\bMatches a word boundary, which is the position between a word and a space. For example,“er\b"can match"never"in"er",but cannot match"verb"in"er"。
\BMatch non-word boundaries。“er\B"can match"verb"in"er",but cannot match"never"in"er"。
\cxMatches 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, treat c as a literal“c"character.
\d Matches a numeric character. Equivalent to [0-9].
\D Matches a non-numeric character. Equivalent to [^0-9].
\f Matches a form feed character. Equivalent to \x0c and \cL.
\n Matches a newline character. Equivalent to \x0a and \cJ.
\rMatches a carriage return character. Equivalent to \x0d and \cM.
\s Matches any whitespace character, including spaces, tabs, form feeds, etc. Equivalent to [ \f\n\r\t\v].
\SMatches any non-whitespace character. Equivalent to [^ \f\n\r\t\v].
\tMatches a tab character. Equivalent to \x09 and \cI.
\vMatches a vertical tab character. Equivalent to \x0b and \cK.
\w Matches any word character including an underscore. Equivalent to“[A-Za-z0-9_]"。
\WMatches any non-word character. Equivalent to“[^A-Za-z0-9_]"。
\xnmatchn,innIs the hexadecimal escape value. The hexadecimal escape value must be exactly two digits long. For example,“\x41"match"A"。"\x041"is equivalent to"\x04&1"。ASCII encoding can be used in regular expressions。.
\nummatchnum,innumis a positive integer. A reference to the match obtained. For example,“(.)\1"Match two consecutive identical characters。
\nIdentifies an octal escape value or a backreference. if\nbefore at leastnobtained subexpressions, thennfor backward reference. Otherwise, ifnis an octal number (0-7), thennis an octal escape value。
\nmIdentifies an octal escape value or a backreference. if\nmThere were at leastnmobtain subexpressions, thennmfor backward reference. if\nmThere were at leastnobtained, thennis followed by textmof backward references. If none of the previous conditions are met, ifnandmare all octal numbers (0-7), then\nmwill match octal escape valuesnm
\nmlifnis an octal number (0-3), andm and lAll are octal numbers(0-7),then matches the octal escape valuenml。
\unmatchn,innis a Unicode character represented by four hexadecimal digits. For example, \u00A9 matches the copyright symbol(©)。
username/^[a-z0-9_-]{3,16}$/
password/^[a-z0-9_-]{6,18}$/
Password 2(?=^.{8,}$)(?=.*\d)(?=.*\W+)(?=.*[A-Z])(?=.*[a-z])(?!.*\n).*$ (By numbers/uppercase letters/lowercase letters/Composed of punctuation marks, all four types must be present, more than 8 characters)
hexadecimal value/^#?([a-f0-9]{6}|[a-f0-9]{3})$/
Email/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
/^[a-z\d]+(\.[a-z\d]+)*@([\da-z](-[\da-z])?)+(\.{1,2}[a-z]+)+$/or\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
URL/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/ or [a-zA-z]+://[^\s]*
IP address/((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)/
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/ or ((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
HTML Label/^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/or<(.*)(.*)>.*<\/\1>|<(.*) \/>
delete code\\Comment(?<!http:|\S)//.*$
Matches double-byte characters (including Chinese characters))[^\x00-\xff]
Kanji (characters)[\u4e00-\u9fa5]
Chinese character range in Unicode encoding/^[\u2E80-\u9FFF]+$/
Chinese and full-width punctuation marks (characters)[\u3000-\u301e\ufe10-\ufe19\ufe30-\ufe44\ufe50-\ufe6b\uff01-\uffee]
Date (year-month-day)(\d{4}|\d{2})-((0?([1-9]))|(1[1|2]))-((0?[1-9])|([12]([1-9]))|(3[0|1]))
Date (month/day/year)((0?[1-9]{1})|(1[1|2]))/(0?[1-9]|([12][1-9])|(3[0|1]))/(\d{4}|\d{2})
Time (hour:minute, 24-hour format)((1|0?)[0-9]|2[0-3]):([0-5][0-9])
Mainland China landline phone number(\d{4}-|\d{3}-)?(\d{8}|\d{7})
Mainland China mobile phone number1\d{10}
Mainland China postal code[1-9]\d{5}
Mainland China ID number (15 or 18 digits)\d{15}(\d\d[0-9xX])?
non-negative integer (positive integer or zero)\d+
positive integer[0-9]*[1-9][0-9]*
negative integer-[0-9]*[1-9][0-9]*
integer-?\d+
decimal(-?\d+)(\.\d+)?
blank line\n\s*\r or \n\n(editplus) or ^[\s\S ]*\n
QQ number[1-9]\d{4,}
Words that do not contain abc\b((?!abc)\w)+\b
Match leading and trailing whitespace characters^\s*|\s*$
Commonly used by editors
Here are some replacements for special Chinese(editplus)
^[0-9].*\n
^[^No].*\n
^[exercise].*\n
^[\s\S ]*\n
^[0-9]*\.
^[\s\S ]*\n
<p[^<>*]>
href="javascript:if\(confirm\('(.*?)'\)\)window\.location='(.*?)'"
<span style=".[^"]*rgb\(255,255,255\)">.[^<>]*</span>
<DIV class=xs0>[\s\S]*?</DIV>

Regular expression syntax

Master the Art of Pattern Matching with the Regex Syntax Cheat Sheet

Hello, coding enthusiasts! 🌟 Are you ready to elevate your text processing skills with the power of regular expressions? Look no further! The Regex Syntax Cheat Sheet is your go-to guide for mastering the syntax of regex patterns.

Introducing the Regex Syntax Cheat Sheet

This comprehensive online resource is designed to assist developers and data analysts in quickly referencing and understanding the syntax of regular expressions. Whether you're a regex novice or a seasoned pro, this cheat sheet is your ally in crafting precise pattern matches.

Key Features of the Regex Syntax Cheat Sheet

  1. Syntax Quick Reference: Get instant access to regex symbols and their functions.
  2. Code Generation: Generate regex codes for various programming languages.
  3. HTML Filtering Tool: Clean up HTML content with regex patterns.
  4. Common Regex Patterns: Explore a collection of commonly used regex expressions.
  5. Regex Test Tool: Test your regex patterns directly within the tool.
  6. XPath Tool Integration: Use regex in conjunction with XPath expressions for advanced data manipulation.

How to Use the Regex Syntax Cheat Sheet

  1. Visit the Regex Syntax Cheat Sheet in your web browser.
  2. Browse through the cheat sheet to find the regex symbols and patterns you need.
  3. Use the provided examples and explanations to understand how each symbol functions.
  4. Test your regex patterns using the integrated test tool.
  5. Apply your newly crafted regex patterns to your projects.

Why Choose the Regex Syntax Cheat Sheet?

  • Efficiency: Save time by quickly finding the regex patterns you need.
  • Comprehensiveness: One resource that covers a wide range of regex symbols and functions.
  • Educational: Enhance your understanding of regex syntax with clear explanations and examples.

Dive into the World of Regular Expressions

Regular expressions are a powerful tool for matching character combinations in strings. Here's a quick overview of some essential regex characters and their descriptions:
  • \|: Marks the next character as special, a literal character, a back reference, or an octal escape.
  • ^: Matches the start of the input string.
  • $: Matches the end of the input string.
  • *: Matches the preceding element zero or more times.
  • +: Matches the preceding element one or more times.
  • ?: Matches the preceding element zero or one time.
  • {n}: Matches exactly n occurrences of the preceding element.
  • {n,}: Matches at least n occurrences of the preceding element.
  • {n,m}: Matches between n and m occurrences of the preceding element.
  • .: Matches any single character except newline characters.
  • (pattern): Matches the pattern and captures it for later use.
  • (?:pattern): Matches the pattern but does not capture it.
  • (?=pattern): Positive lookahead, matching the string that starts with pattern.
  • (?!pattern): Negative lookahead, matching the string that does not start with pattern.

Regex Examples

  • Usernames: ^\[a-z0-9_-\]{3,16}$
  • Passwords: ^\[a-z0-9_-\]{6,18}$
  • Emails: ^(\[a-z0-9_\\.-\]+)@(\[\\da-z\\.-\]+)\\.(\[a-z\\.\]{2,6})$
  • URLs: ^(https?:\\/\\/)?(\[\\da-z\\.-\]+)\\.(\[a-z\\.\]{2,6})(\[\\/\\w \\.-\]\*)\\/?$

your footprints:

Friendly links: Network ToolboxNetwork Toolbox News