java正则表达式

一、过滤视图名称的正则表达式:
 
1.包含-la的
 
^[pa].+-la.+
 
 
2.P开头包含scm的
 
^p.+scm.+
 
 
3.我的视图
 
(^[pa].+-la.+)|(^p.+(crm-|a-)domain-(sim|res)$)|(.+crm-res)|(^p.+scm.+)
 
Date d/m/yy and dd/mm/yyyy
1/1/00 through 31/12/99 and 01/01/1900 through 31/12/2099
Matches invalid dates such as February 31st
Accepts dashes, spaces, forward slashes and dots as date separators
\b(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2}\b
 
Date dd/mm/yyyy
01/01/1900 through 31/12/2099
Matches invalid dates such as February 31st
Accepts dashes, spaces, forward slashes and dots as date separators
(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)[0-9]{2}
 
Date m/d/y and mm/dd/yyyy
1/1/99 through 12/31/99 and 01/01/1900 through 12/31/2099
Matches invalid dates such as February 31st
Accepts dashes, spaces, forward slashes and dots as date separators
\b(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2}\b
 
Date mm/dd/yyyy
01/01/1900 through 12/31/2099
Matches invalid dates such as February 31st
Accepts dashes, spaces, forward slashes and dots as date separators
(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)[0-9]{2}
 
Date yy-m-d or yyyy-mm-dd
00-1-1 through 99-12-31 and 1900-01-01 through 2099-12-31
Matches invalid dates such as February 31st
Accepts dashes, spaces, forward slashes and dots as date separators
\b(19|20)?[0-9]{2}[- /.](0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])\b
 
Date yyyy-mm-dd
1900-01-01 through 2099-12-31
Matches invalid dates such as February 31st
Accepts dashes, spaces, forward slashes and dots as date separators
(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])
 
Domain name
\b([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b
 
Domain name (anchored)
^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$
 
Domain name (internationalized)
Allow internationalized domains using punycode notation, as well as regular domain names
\b((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}\b
 
Domain name (internationalized, strict)
Allow internationalized domains using punycode notation, as well as regular domain names
Use lookahead to check that each part of the domain name is 63 characters or less
\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b
 
 
Domain name (strict)
Use lookahead to check that each part of the domain name is 63 characters or less
\b((?=[a-z0-9-]{1,63}\.)[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b
 
Email address
Use this version to seek out email addresses in random documents and texts.
Does not match email addresses using an IP address instead of a domain name.
Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.  Including these increases the risk of false positives when applying the regex to random documents.
Requires the "case insensitive" option to be ON.
\b[A-Z0-9_%+-]+@[A-Z0-9]+\.[A-Z]{2,6}\b
 
 
Email address (anchored)
Use this anchored version to check if a valid email address was entered.
Does not match email addresses using an IP address instead of a domain name.
Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.
Requires the "case insensitive" option to be ON.
^[A-Z0-9_%+-]+@[A-Z0-9]+\.[A-Z]{2,6}$
 
Email address (anchored; no consecutive dots)
Use this anchored version to check if a valid email address was entered.
Improves on the original email address regex by excluding addresses with consecutive dots such as john@aol...com
Does not match email addresses using an IP address instead of a domain name.
Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.  Including these increases the risk of false positives when applying the regex to random documents.
Requires the "case insensitive" option to be ON.
^[A-Z0-9_%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}$
 
Email address (no consecutive dots)
Use this version to seek out email addresses in random documents and texts.
Improves on the original email address regex by excluding addresses with consecutive dots such as john@aol...com
Does not match email addresses using an IP address instead of a domain name.
Does not match email addresses on new-fangled top-level domains with more than 4 letters such as .museum.  Including these increases the risk of false positives when applying the regex to random documents.
Requires the "case insensitive" option to be ON.
\b[A-Z0-9_%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6}\b
 
Email address (specific TLDs)
Does not match email addresses using an IP address instead of a domain name.
Matches all country code top level domains, and specific common top level domains.
Requires the "case insensitive" option to be ON.
^[A-Z0-9_%+-]+@[A-Z0-9]+\.(?:asia|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[A-Z]{2})$
 
Email address: Replace with HTML link
\b(?:mailto:)?([A-Z0-9_%+-]+@(?:[A-Z0-9-]+\.)+[A-Z]{2,6})\b<a href="mailto:$1">$0</a>
 
 
Email address: RFC 2822
This regular expression implements the official RFC 2822 standard for email addresses.  Using this regular expression in actual applications is NOT recommended.  It is shown to illustrate that with regular expressions there's always a trade-off between what's exact and what's practical.
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?: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]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
 
Email address: RFC 2822 (simplified)
Matches a normal email address.  Does not check the top-level domain.
Requires the "case insensitive" option to be ON.
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
 
Email address: RFC 2822 (specific TLDs)
Matches all country code top level domains, and specific common top level domains.
Requires the "case insensitive" option to be ON.
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|asia|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel)\b
 
 
IPv4 address (accurate capture)
Matches 0.0.0.0 through 255.255.255.255
Use this regex to match IP numbers with accurracy.
Each of the 4 numbers is stored into a capturing group, so you can access them for further processing.
\b(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b
 
 
IPv4 address (accurate capture, anchored)
Matches 0.0.0.0 through 255.255.255.255
Use this regex to match IP numbers with accurracy.
Each of the 4 numbers is stored into a capturing group, so you can access them for further processing.
^(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$
 
 
 
IPv4 address (accurate)
Matches 0.0.0.0 through 255.255.255.255
Use this regex to match IP numbers with accurracy, without access to the individual IP numbers.
\b(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\b
 
 
IPv4 address (accurate, anchored)
Matches 0.0.0.0 through 255.255.255.255
Use this regex to match IP numbers with accurracy, without access to the individual IP numbers.
^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$
 
 
IPv4 address (simple capture)
Matches 0.0.0.0 through 999.999.999.999
Use this fast and simple regex if you know the data does not contain invalid IP addresses.
Each of the 4 numbers is stored into a capturing group, so you can access them for further processing.
\b([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\b
 
 
IPv4 address (simple)
Matches 0.0.0.0 through 999.999.999.999
Use this fast and simple regex if you know the data does not contain invalid IP addresses, and you don't need access to the individual IP numbers.
\b(?:[0-9]{1,3}\.){3}[0-9]{1,3}\b
 
 
Words: Any word NOT matching a particular regex
This regex will match all words that cannot be matched by %REGEX%.
Explanation: Observe that the negative lookahead and the \w+ are repeated together.  This makes sure we test that %REGEX% fails at EVERY position in the word, and not just at any particular position.
\b(?:(?!%REGEX%)\w)+\b
 
Words: Delete repeated words
Find any word that occurs twice or more in a row.
Delete all occurrences except the first.
\b(\w+)(?:\s+\1\b)+ $1
 
 
Words: Near, any order
Matches word1 and word2, or vice versa, separated by at least 1 and at most 3 words
\b(?:word1(?:\W+\w+){1,3}?\W+word2|word2(?:\W+\w+){1,3}?\W+word1)\b
 
Words: Near, list
Matches any pair of words out of the list word1, word2, word3, separated by at least 1 and at most 6 words
\b(word1|word2|word3)(?:\W+\w+){1,6}?\W+(word1|word2|word3)\b
 
 
Words: Near, ordered
Matches word1 and word2, in that order, separated by at least 1 and at most 3 words
\bword1(?:\W+\w+){1,3}?\W+word2\b
 
Words: Repeated words
Find any word that occurs twice or more in a row.
\b(\w+)\s+\1\b
 
Words: Whole word
\b%WORD%\b
 
Words: Whole word
Match one of the words from the list
\b(?:word1|word2|word3)\b
 
 
Words: Whole word at the end of a line
Whitespace permitted after the word
\b%WORD%\s*$
 
 
Words: Whole word at the start of a line
Whitespace permitted before the word
^\s*%WORD%\b
 
 
Words: Whole word at the very end of a line
\b%WORD%$
 
 
Words: Whole word at the very start of a line
^%WORD%\b
 
Number: Currency amount (cents optional)
Optional thousands separators; optional two-digit fraction
^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*(?:\.[0-9]{2})?$
 
 
 
Number: Currency amount (cents mandatory)
Optional thousands separators; mandatory two-digit fraction
^[+-]?[0-9]{1,3}(?:,?[0-9]{3})*\.[0-9]{2}$
 
 
Number: Currency amount US & EU (cents optional)
Can use US-style 123,456.78 notation and European-style 123.456,78 notation.  Optional thousands separators; optional two-digit fraction
^[+-]?[0-9]{1,3}(?:[0-9]*(?:[,][0-9]{2})?|(?:,[0-9]{3})*(?:\.[0-9]{2})?|(?:\.[0-9]{3})*(?:,[0-9]{2})?)$
 
Number: floating point
Matches an integer or a floating point number with mandatory integer part.  The sign is optional.
[-+]?\b[0-9]+(\.[0-9]+)?\b
 
Number: floating point
Matches an integer or a floating point number with optional integer part.  The sign is optional.
[-+]?\b[0-9]*\.?[0-9]+\b
 
 
Number: floating point (anchored)
Matches an integer or a floating point number with mandatory integer part.  The sign is optional.
^[-+]?[0-9]+(\.[0-9]+)?$
 
 
Number: floating point (anchored)
Matches an integer or a floating point number with optional integer part.  The sign is optional.
^[-+]?[0-9]*\.?[0-9]+\b$
 
 
Number: hexadecimal (C-style)
\b0[xX][0-9a-fA-F]+\b
 
 
Number: Insert thousands separators
Replaces 123456789.00 with 123,456,789.00
(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9])) ,
 
Number: integer
Will match 123 and 456 as separate integer numbers in 123.456
\b\d+\b
 
 
Number: integer
Does not match numbers like 123.456
(?<!\S)\d++(?!\S)
 
 
Number: integer (anchored)
The whole string must consist of only digits
^\d+$
 
 
Number: integer with optional sign
[-+]?\b\d+\b
 
 
Number: integer with optional sign (anchored)
^[-+]?\d+$
 
 
Number: scientific floating point
Matches an integer or a floating point number.
Integer and fractional parts are both optional.
Both the sign and exponent are optional.
[-+]?(?:\b[0-9]+(?:\.[0-9]*)?|\.[0-9]+\b)(?:[eE][-+]?[0-9]+\b)?
 
Number: scientific floating point
Matches an integer or a floating point number with optional integer part.
Both the sign and exponent are optional.
[-+]?\b[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?\b
 
 
Number: scientific floating point (anchored)
Matches an integer or a floating point number.
Integer and fractional parts are both optional.
Both the sign and exponent are optional.
^[-+]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$
 
 
Number: scientific floating point (anchored)
Matches an integer or a floating point number with optional integer part.
Both the sign and exponent are optional.
^[-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?$
 
Numeric range: 0 or 00..59
^[0-5]?[0-9]$
 
Numeric range: 0 or 000..127
^(0?[0-9]?[0-9]|1[0-1][0-9]|12[0-7])$
 
 
Numeric range: 0 or 000..255
^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$
 
 
Numeric range: 0 or 000..366
^(0?[0-9]?[0-9]|[1-2][0-9][0-9]|3[0-6][0-9]|36[0-6])$
 
Numeric range: 0 or 000..999
^[0-9]{1,3}$
 
 
Numeric range: 0..255
^([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$
 
 
Numeric range: 0..999
^([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$
 
 
Numeric range: 000..255
^([01][0-9][0-9]|2[0-4][0-9]|25[0-5])$
 
 
Numeric range: 000..999
^[0-9]{3}$
 
 
Numeric range: 001..999
^(00[1-9]|0[1-9][0-9]|[1-9][0-9][0-9])$
 
Numeric range: 1 or 001..999
^(0{0,2}[1-9]|0?[1-9][0-9]|[1-9][0-9][0-9])$
 
Numeric range: 1..999
^([1-9]|[1-9][0-9]|[1-9][0-9][0-9])$
 
 
Password complexity (alphanumeric)
Tests if the input consists of 6 or more letters, digits, underscores and hyphens.
The input must contain at least one upper case letter, one lower case letter and one digit.
\A(?=[-_a-zA-Z0-9]*?[A-Z])(?=[-_a-zA-Z0-9]*?[a-z])(?=[-_a-zA-Z0-9]*?[0-9])[-_a-zA-Z0-9]{6,}\z
 
Password complexity (ASCII)
Tests if the input consists of 6 or more ASCII characters.
The input must contain at least one upper case letter, one lower case letter and one digit.
\A(?=[\x20-\x7E]*?[A-Z])(?=[\x20-\x7E]*?[a-z])(?=[\x20-\x7E]*?[0-9])[\x20-\x7E]{6,}\z
 
 
 
 
\b(?:(?!%REGEX%)\w)+\b
 
\b(\w+)(?:\s+\1\b)+ $1
 
\b(?:word1(?:\W+\w+){1,3}?\W+word2|word2(?:\W+\w+){1,3}?\W+word1)\b
 
\b(word1|word2|word3)(?:\W+\w+){1,6}?\W+(word1|word2|word3)\b
 
\b(\w+)\s+\1\b
 
\b%WORD%\b
 
\b(?:word1|word2|word3)\b
 
\b%WORD%\s*$
 
^\s*%WORD%\b
 
\b%WORD%$
 
^%WORD%\b
posted @ 2020-07-05 15:58  heycomputer  阅读(150)  评论(0编辑  收藏  举报