定期表达以下字符串 [英] Regular expressing for the following string
本文介绍了定期表达以下字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有字符串,其字母数字如下所示。
例1:abc1232323acvc23232avac
Ex 2:abc1232bcsb
这里我想检查字符串是否为字母数字以及连续数字长度不应超过7.
我试过但我无法得到正确的正则表达式。
请帮助我这个
我尝试了什么:
尝试用
I have string with is having the alpha numeric noted as below.
Ex 1: abc1232323acvc23232avac
Ex 2: abc1232bcsb
Here I want to check the string is alpha number as well as continuous numeric length should not exceed more than 7.
I have tried but I couldn't get the proper regular expression.
Kindly help me on this
What I have tried:
Tried with
(([a-z]+[0-9]+)+|(([0-9]+[a-z]+)+))[0-9a-z]{0.7}*
推荐答案
您的RegEx很奇怪,替换{0.7}
带{0,7}
来控制重复。最后的*
也是一个错误。
使用上一个链接查看你的RegEx的一个很好的图表,它可能有助于理解什么是错误。
几个有趣的链接,帮助构建和调试RegEx。
以下是RegEx文档的链接:
perlre - perldoc.perl.org [ ^ ]
以下是帮助构建RegEx并调试它们的工具的链接:
.NET正则表达式测试程序 - 正则表达式风暴 [ ^ ]
Expresso正则表达式工具 [ ^ ]
RegExr:Learn,Build,&测试RegEx [ ^ ]
此节目RegEx是一个很好的图表,它非常有助于理解RegEx的作用:
Debuggex:在线可视正则表达式测试器。 JavaScript,Python和PCRE。 [ ^ ]
Your RegEx is weird, replace{0.7}
with{0,7}
to control repeat. The*
at the end is an error too.
Use last link to see a nice diagram of your RegEx, it may help to anderstand what is wrong.
Just a few interesting links to help building and debugging RegEx.
Here is a link to RegEx documentation:
perlre - perldoc.perl.org[^]
Here is links to tools to help build RegEx and debug them:
.NET Regex Tester - Regex Storm[^]
Expresso Regular Expression Tool[^]
RegExr: Learn, Build, & Test RegEx[^]
This one show you the RegEx as a nice graph which is really helpful to understand what is doing a RegEx:
Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]
这篇关于定期表达以下字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文