开发者

What's the regular expression to determine if the last two characters of string are 'R' and a number?

开发者 https://www.devze.com 2023-02-19 15:05 出处:网络
I need a regex to determine if a given string ends with \'R\' and then a single digit (0-9) for instance TESTR3 would be what I\'m looking for whereas 开发者_如何学编程TESTR34 would not.Like so:

I need a regex to determine if a given string ends with 'R' and then a single digit (0-9) for instance TESTR3 would be what I'm looking for whereas 开发者_如何学编程TESTR34 would not.


Like so:

Regex rx = new Regex("R[0-9]$");

Edit: Reverted to [0-9] to avoid matching characters like ٠١٢٣٤٥٦٧٨٩


The expression R\d$ should work.


Use something like: R[0-9]$

http://regexlib.com/CheatSheet.aspx is always helpful as well.

0

精彩评论

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