什么是 3 个连续数字递增或递减的正则表达式模式 [英] What's a Regex pattern for 3 consecutive digits increasing or decreasing
本文介绍了什么是 3 个连续数字递增或递减的正则表达式模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个正则表达式模式来匹配字符串中连续增加或减少的 3 个连续数字的序列.
I need a regex pattern to match a sequence of 3 consecutive digits in a string that are consecutively increasing or decreasing.
例如:
这些字符串应该匹配 (xxx123xxx, 789xxxxxx, xxxxxx987, xxxxxx432)
These strings should match (xxx123xxx, 789xxxxxx, xxxxxx987, xxxxxx432)
这些字符串不应该匹配 (xxxxxx454, 333xxxxxx, xxx429xxx)
These strings should not match (xxxxxx454, 333xxxxxx, xxx429xxx)
推荐答案
除了列出它们别无他法:
There is no other way than listing them:
(012|123|234|345|456|567|678|789|987|876|765|654|543|432|321|210)
这篇关于什么是 3 个连续数字递增或递减的正则表达式模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文