简体   繁体   English

正则表达式字母/数字组合

[英]Regex For Letters/Numbers combination

Trying to come up with a regex to capture groups like AB1234 or BA2321 . 试图提出一个正则表达式来捕获AB1234BA2321类的组。 Essentially need to capture anything that starts with AB or BA and followed by 4 digits. 基本上需要捕获以AB或BA开头,后跟4位数字的所有内容。

Currently, I have something like this, but that seems to not take numbers into account 目前,我有这样的事情,但这似乎没有考虑到数字

(AB|BA)\d{4}

May be you want: 可能是您想要的:

\b((?:AB|BA)\d{4})\b

Letters + digits will be in group 1 字母和数字将在组1中

我会用这个:

^(AB|BA)\d{4}$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM