简体   繁体   English

匹配奇数长度的字符串

[英]Match string of odd length

Im trying to construct a regular expression to just match if the length of the string is odd. 我试图构造一个正则表达式,以匹配字符串的长度是奇数。 I have not had any success so far. 到目前为止我还没有取得任何成功。

2313432 - true 2313432 - 是的

12 - false 12 - 假

121111111111111 - true 121111111111111 - 是的

Thanks 谢谢

You want this regular expression: 你想要这个正则表达式:

^.(..)*$

This says, match one character, then zero or more sets of two characters, all of which is anchored to the start and end of the string. 这说,匹配一个字符,然后是零个或多个两个字符集,所有这些字符都锚定到字符串的开头和结尾。

怎么样的东西: ^(..)*.$

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

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