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 match consecutive numbers with regular expressions

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the regular expression how to match consecutive numbers, the article is very detailed, has a certain reference value, interested friends must read it!

The requirements for implementation are as follows:

Pure number

Between 5 and 7 digits

The first three are the same.

Continuous from the fourth place.

Such as the following example:

11123 # correct 22234 # correct 33345 # correct 2223456 # correct 0001234 # correct 00012345 # error: the length of this line exceeds the standard 000234 # error: bit 3 and bit 4 are not contiguous 111235 # error: bit 5 and bit 6 are not contiguous

1. Match three identical digits

(\ d)\ 1 {2}

2. Match consecutive digits

Matching consecutive numbers can be matched by zero-width assertions, of course, there is no good way, can only be enumerated, the following two lines can match 3 consecutive digits

(0 (? = 1) | 1 (? = 2) | 2 (3) | 3 (4) | 4 (5) | 5 (6) | 6 (7) | 7 (8) | 8 (9)) {2}\ d\ d ((?)

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