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

\ {\} in regular expressions-- the number of times matching patterns occur

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Regular expression:

The number of times matching characters appear

Use * to match all the matching results once, but if you only need to set the number of times, you should use\ {}. There are three forms of this pattern.

Pattern\ {n\} matching pattern occurs n times

Pattern\ {n,\} matching patterns occur at least n times

Pattern\ {NMagne m\} matching pattern occurs n to m times, and nMagne m is an arbitrary integer between 0 and 255respectively.

Example:

A\ {2\} B matching value is AAB

A\ {4\} B matching value is AAAAB or AAAAAAB, but cannot be AAAB

A\ {3pm 5\} matching value is AAAB,AAAAB,AAAAAB

Note: it is not difficult for regular expressions to use a single metacharacter, especially if multiple metacharacter sets are mixed.

Grep'^ H. [Amurz Zjinaqizi] s\ {2pr 4\} c$'./test

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

Internet Technology

Wechat

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

12
Report