Odd Length Match String

Im trying to build a regex just to match if the string length is odd. I have not yet succeeded.

2313432 - true

12 - false

121111111111111 - true

thank

+3
source share
2 answers

You want this regular expression:

^.(..)*$

This means that it matches one character, then zero or more sets of two characters, all of which are tied to the beginning and end of the line.

+11
source

How about something like ^(..)*.$:?

+4
source

Source: https://habr.com/ru/post/1757587/


All Articles