正则表达式if else [英] Regular Expression if else
本文介绍了正则表达式if else的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好
我正在寻找如何使用if else语句创建正则表达式。我想创建一个只允许波纹图案的正则表达式
ANANNNNN
ANNANNNN
NANNNNNN
其中A = [az,AZ]
N = [0-9]
感谢您的帮助
谢谢
解决方案
假设这些只是示例,你想要任何具有这种格式的东西:
[a- zA-Z] \d + [a-zA-Z] \d + | \d [a-zA-Z] \d +
如果你想要的话你所展示的是:
[a-zA-Z] \d [a-zA-Z] \d {5} | [a-zA -Z] \d\d [A-ZA-Z] \d {4} | \d [A-ZA-Z] \d {6}
Hi There
I am looking how to create regular expression with if else statement on. what I wanted to create a regular expression which allow only the bellow patterns
ANANNNNN
ANNANNNN
NANNNNNN
where A =[a-z,A-Z]
N=[0-9]
appreciate your help
thanks
解决方案
Assuming those are just examples and you want anything with that kind of format:
[a-zA-Z]\d+[a-zA-Z]\d+|\d[a-zA-Z]\d+
If you want exactly what you show, then:
[a-zA-Z]\d[a-zA-Z]\d{5}|[a-zA-Z]\d\d[a-zA-Z]\d{4}|\d[a-zA-Z]\d{6}
这篇关于正则表达式if else的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文