ImportJava.util.regex.Matcher; ImportJava.util.regex.Pattern; Importjava.util.regex.PatternSyntaxException; Public classPhoneformatcheckutils {/*** Mainland or Hong Kong numbers are available*/ Public Static BooleanIsphonelegal (String str)throwspatternsyntaxexception {returnIschinaphonelegal (str) | |Ishkphonelegal (str); } /*** Mainland Mobile phone number 11 digits, match format: first three bit fixed format + 8 digits any number * This method in the first three bit format has:
sharp number before a match can be reached. \d+ matches 1 to multiple digits. English question mark? Indicates that 0~1 can appear. \. The match is the character ".", and the parentheses (parentheses) represent a grouping. So this regular expression can match a positive integer or a decimal number, such as: "5", "66.6" or "5.21", and so on.
Note that the Chinese full-width space () character is n
In this case, the regular expression optimization, mainly for the current commonly used NFA pattern regular expressions, in detail can be referred to: regular expression matching parsing process analysis (regular
to use regular expression syntax to describe the pattern of characters. JavaScript is a fairly complete subset of the regular expression syntax for Perl language .
The pattern specification for regular expressions is made up of a series of characters. Most characters, inclu
same.Reverse pre-search: "(? The concept of these two formats and forward pre-search is similar, the requirement for reverse pre-search is: "left side" of the gap, the two formats must be able to match and must not match the specified expression, rather than to judge the right. As with forward pre-search, they are an additional condition to the slot in which they do not match any characters.Example 5: Expression
do a certain string lookup, but regular expressions can help us to do Fuzzy Lookup, faster and more convenient, just need a regular expression string.
3, various languages are basically supportedRegular expressions are currently supported in mainstream languages such as Java, PHP, Javascript, C #, and C + +.
4, the
-]+) *@[\\w-]+ (\\.[ \\w-]+) +$ "//email address
"^[a-za-z]+://(\\w+ (-\\w+) *) (\ \\w+ (-\\w+) *)) * (\\?\\s*) $ "//url
"^[a-za-z0-9_]*$"
The use of regular expressions in the detailed
Brief introduction
In short, regular expressions are a powerful tool that can be used for pattern matching and substitution. Its role is as follows:
Tests a pattern of a string. For example, you can test an input string to s
PHP regular expression full manual, regular expression full manual
Php regular expression full manual
Preface
Regular Expressions are cumbersome, but they are powerful. The application
NFA constructs a specific extension of a regular expression to achieve a successful match, it can capture the subexpression matching and matching reverse references. However, because of the traditional NFA backtracking, it can access the exact same state multiple times (if the state is reached through a different path). Therefore, at worst, it can perform very slowly. Because the traditional NFA accepts th
, and approximately 3 days after 400 years, thus reducing the 400 leap year in every three years. Leap year calculation, summed up is usually said: four years a leap, hundred years does not leap, 400 year again leap.
2.3 Format of the date
Depending on the language and culture, the hyphen of the date will vary, usually in the following formats:
YyyyMMdd
Yyyy-mm-dd
Yyyy/mm/dd
yyyy. Mm.dd
Regular expression
, up to 25 bits, the user name immediately after the @, followed by the domain name, domain names can only contain alphanumeric and minus sign (-), and can not start or end with a minus sign, Then there is the domain suffix (there can be more than one), the domain name suffix must be dot number connected to 2-4 charactersJS CodeCopy CodeThe code is as follows:var re =/^\w{1,15} (?: @ (?! -)) (?:(?: [a-z0-9-]*) (?: [A-z0-9] (?! -))(?:\. (?!-))) +[a-z]{2,4}$/; Articles you may be interested in:
Objective:
Six months ago, I was interested in regular expressions, found a lot of information on the Internet, read a lot of tutorials, and finally in the use of a regular expression tool Regexbuddy to find his tutorial written very well, can be said that I have seen the best regu
meaning
{N,m}
Matches the previous item at least n times, but not more than m times
{N,}
Match the previous item at least n times
N
Match the previous top n times
?
Matches the previous item 0 or 1 times, which means the previous item is optional, equivalent to {0,1}
+
Matches 1 or more times before, equivalent to {1,}
*
Matches 0 or more times before, equivalent to {0,}
Here ar
clusters
7.3_ OK repeat occurrence
1. Intro
At present, regular expressions have been widely used in many software applications, including *nix (Linux, UNIX, etc.), HP and other operating systems, Php,c#,java and other development environments, as well as many applications, can see the shadow of regular expression.
T
Objective
Regular expression is cumbersome, but powerful, after the application of learning will let you in addition to improve efficiency, will give you a sense of absolute achievement. As long as the careful reading of these materials, coupled with the application of a certain reference, master regular expression is
Java 8 Lambda expression tutorial
1. What is a Lambda expression?
Lambda expressions are essentially an anonymous method. Let's take a look at the following example:
Public int add (int x, int y ){Return x + y;}
After converting it to a Lambda expression, it looks like this:
. The specific descriptions are as follows:
Character
Replace text
$1, $2,..., $99
Text that matches the 1st to 99 subexpressions in regexp
$
String Matching regexp
$'
Text on the left of the matched substring
$'
Text on the right of the matched substring
$
Direct Volume symbol
Let's take a look at the following example:
// 1. Replace with a subexpression: var str = "javascript"; str.
As with the MySQL comprehensive optimization detailed in the previous writing, it is because such tools are widely used, so a comprehensive optimization strategy for such tools is a good deal, because whether you're a programmer in PHP, Perl, Python, C + +, C #, Java, and so on, You are very likely to use a tool such as MySQL, regular expressions.
Let's say something you may not know. Knowledge of
up of a series of characters. Most characters, including all alphanumeric characters, describe characters that are matched literally. In this case, the regular expression/java/and all of the containing substring "Java" String. Although the other characters in the regular
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.