开发者

How to match strings that start and end with the same character, but have an odd number of letters?

开发者 https://www.devze.com 2023-03-05 07:28 出处:网络
I\'m trying to formulate a regex that identifies strings that begin and end with \'B\" but also have an odd number of letters overall. So far I have 开发者_如何学JAVAthe following:

I'm trying to formulate a regex that identifies strings that begin and end with 'B" but also have an odd number of letters overall. So far I have 开发者_如何学JAVAthe following:

Strings that start and end with B:

^B.*B$

I am not sure how to get it so that it only accepts an odd number of letter. For even numbers it's easy:

^B(..)*B$ 

But odd is throwing me a little


It should be almost the same:

^B.(..)*B$
0

精彩评论

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