Difference between (brackets) [square brackets] {curly brackets} in regular expressions

I encountered a problem in the small requirement of using regularity to judge the input string before, and I don't know how to judge the continuous string. 
Such as .com .cn .net at the end of the mailbox.

So check the information:

Parentheses (): Parentheses are multiple matches. It treats the ones in the parentheses as a group, and limits the scope of some multiple choices. For example, the above requirement can only be that the parentheses at the end of com cn net are the best choice. 
Parentheses can extract strings, such as (com|cn|net) can be limited, only com or cn or net. 
The parentheses treat the contents inside the parentheses as a group, which is the difference from [].

Square brackets []: Square brackets are a single match, such as [abc], which restricts the continuous occurrence of abc, but only one of them. If you write this way, the rule is that when you find this position, it can only be a or b or c ; 
Square brackets are the most commonly used in regular expressions. Common usages are: [a-zA-Z0-9] matches all English letters and numbers, [^a-zA-Z0-9] matches all non-English letters and numbers .

Braces {}: The usage of braces is very simple, it is the number of matches, it needs to be used together with other meaningful regular expressions. 
For example, [ac]{2} means to match a letter between ac and only appear twice; for 
example (com){1} means that com must appear once 
. For example, \W{1,3} means the least non-alphanumeric Occurs up to 3 times at a time.

Summary: Regular expressions look complicated, but they feel like a sequence from left to right is easy to learn. Although regular expressions are easy to understand, it is not easy to apply them flexibly.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325452045&siteId=291194637