Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand regular expressions

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report