Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand regular expressions

Shulou Source: shulou.com Published: 2022-06-02 10:38:06 09月28日 Update

How to understand regular expressions, I believe that many inexperienced people do not know what to do. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

What is a regular expression?

Regular _ Expression (RE) is a character pattern (Pattern) that is used to match a specified character during a lookup. In most programs, regular expressions are placed between positive and double slashes (/ /).

Metacharacter

Function ^ line first locator

$

End of line locator. Match single character * match 0 or more repeated characters in front of an asterisk [] match any one of a set of characters [^] match characters that are not within the specified range\ to translate metacharacter x\ {m\} character x repeat m times,\} character x at least m times x\ {m The n\} character x appears m to n times\ the suffix locator\ (..\) matches the label of the character to be used later. You can use up to 9 tags

Train of thought expansion:

Regular expression comment / ^ [Amurz]. $/ begins with an uppercase letter, followed by two arbitrary characters, followed by a newline line / ^ [Amurz] [amurz] * 3 [0-5] / begins with an uppercase letter, followed by 0 or more lowercase letters A line with a number between 3 and 0-5 followed by a line / [a murz] *\. / 0 or more lowercase letters followed by a full stop line / ^ [A-Za-z] * [^,] [A-Za-z] * $/ 0 or more letters, no comma in the middle, lines ending with 0 or more letters / ^ $/ blank /. * / any character /\ / begins with c, followed by 0 or more arbitrary characters (. *) Then replace the string s /\ ([Oo] ccur\) ence/\ 1rence/g at the end of bo with [Oo] ccurence instead of [Oo] ccurrence. Do you know how to understand regular expressions? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Characters letters regular expressions multiple followed beginning positioning between metacharacters content uppercase uppercase letters lowercase numbers methods more labels problems at a loss Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi Linux Redmi Docker