简体   繁体   English

需要正则表达式专业知识

[英]Need regular expression expertise

I need help figuring out a regular expression for the rule: 我需要帮助找出规则的正则表达式:

6 characters, starting with letter R (uppercase), and followed by digits where at least one digit is not 0. 6个字符,以字母R(大写)开头,后跟数字,其中至少一位数字不为0。

My attempt so far is "[R][0-9]{5}[1-9]+" but I keep getting a false when it should be returning true for R01001. 到目前为止,我的尝试是"[R][0-9]{5}[1-9]+"但是当R01001应该返回true时,我一直收到错误消息。 I'm stumped, Any help would be appreciated. 我很沮丧,任何帮助将不胜感激。

You can use: 您可以使用:

^R(?=0*[1-9])[0-9]{5}$

Working Demo: http://regex101.com/r/bA7yI9 工作演示: http : //regex101.com/r/bA7yI9

Explanation: 说明:

在此处输入图片说明

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

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