开发者

Regular expression to match 'R33' and 'r34E' [closed]

开发者 https://www.devze.com 2023-01-31 04:17 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 8 years ago.

Improve this question 开发者_如何转开发

I am looking for a regular expression that matches R33 and r34E. I tried (R|r)[0-9]{2}+[A-Z]{1} but got an error.


/[rR][0-9]{2}[A-Z]?/


It is an invalid Regular Expression. If you want to have 2 or more digits, {2}+ won't work, you should use {2,}.

(R|r)[0-9]{2,}[A-Z]?


[0-9]{2}+

That plus sign looks wrong. If you take that out:

(R|r)[0-9]{2}[A-Z]?

Appears to do what you want (upper- or lowercase R, two digits, optionally any uppercase letter).


Try ^(R|r)[0-9]{2}$|^(R|r)[0-9]{2}[A-Z]{1}$


Your regex is invalid.

You can use {2} or + on an expression, but not both.

0

精彩评论

暂无评论...
验证码 换一张
取 消