Regular
Let's start with a simple first. Let's say you're searching for a string that contains the character "cat", and the regular expression for the search is "cat." If the search is not sensitive to case, the word "catalog", "Catherine", "sophisticated" can all match. Other words:
1.1 Period Symbol Suppose you are playing English Scrabble, you want to find three-letter words, and these words must start with the "T" letter, End with "n" letter. In addition, suppose you have an English dictionary, you can use regular expressions to search all of its contents. To construct this regular expression, you can use a wildcard character-the period symbol ".". In this way, the complete expression is "T.N", which matches "tan", "ten", "Tin" and "ton", and also matches "T#n", "TPN" or even "T n", and many other meaningless combinations. This is because the period symbol matches all characters, including spaces, tab characters, and even line breaks:
1.2 bracket Notation in order to solve the problem that the period symbol matching range is too broad, you can specify a meaningful character in square brackets ("[]"). At this point, only the character character character specified in the square brackets participate in the match. That is, the regular expression "t[aeio]n" matches only "tan", "Ten", "Tin", and "ton". But "Toon" does not match, because within the square brackets you can only match a single character:
1.3 "or" symbol if you want to match "toon" except for all the words above, you can use the "|" Operator. | The basic meaning of an operator is the "or" operation. to match "Toon", use the "t (A|e|i|o|oo) n" Regular expression. You cannot use a square extension here because the brackets allow only a single character to be matched, and you must use the parentheses "()" here. Parentheses can also be used to group, as described later in this article.
1.4 Symbol table showing the number of matches the symbol that represents the number of matches is used to determine the number of occurrences of the symbol immediately to the left of the symbol:
Suppose we want to search the U.S. Social Security number in a text file. The format of this number is 999-99-9999. The regular expression used to match it is shown in figure one. In a regular expression, a hyphen ("-") has a special meaning, which represents a range, for example, from 0 to 9. Therefore, when matching the hyphenation symbol in the social security number, it is preceded by an escape character "\".
Figure I: Matches all 123-12-1234 forms of Social Security number hypothesis when searching, you want the hyphen to appear or not to appear-that is, 999-99-9999 and 999999999 are in the correct format. At this point, you can add the word "? The quantity qualifier symbol, as shown in Figure two:
Figure II: Matching Social Security numbers in all 123-12-1234 and 123121234 forms Let's look at another example. A format for U.S. car licences is four digits plus two letters. Its regular expression is preceded by the number part "[0-9]{4}", plus the letter part "[A-z]{2}". Figure three shows the complete regular expression.
Figure three: Match a typical U.S. car license number, such as 8836kv1.5 "no" symbol "^" symbol called "no" symbol. If used in square brackets, "^" denotes a character that you do not want to match. For example, the regular expression in Figure four matches all words except words that begin with the "X" letter.
Figure IV: Matches all words except the 1.6 parentheses and whitespace symbols that begin with "X" Suppose you want to extract the month portion from a birthday date formatted with "June 26, 1951", and a regular expression to match that date can be as shown in Figure five:
Figure Five: A date that matches all moth dd,yyyy formats the new "\s" symbol is a blank symbol that matches all whitespace characters, including the tab character. If the string matches correctly, then how do you extract the month portion? Simply create a group with parentheses around the month, and then extract its value with the Oro API (discussed in detail later in this article). The modified regular expression is shown in Figure six:
Figure VI: Matches the date of all month dd,yyyy formats, defining the month value as the first group
1.7 Other symbols for simplicity, you can use some shortcut symbols that are created for common regular expressions. As shown in table two: Table two: Common symbols
For example, in the previous example of social Security numbers, "\d" can be used in all places where "[0-9]" appears. The modified regular expression is shown in Figure seven:
Figure VII: Matching Social Security numbers in all 123-12-1234 formats