开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜