Skip to main content
saved 4 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!


Without a regular expression, 33 33  29 bytes

Returns a Boolean valueeither null (falsy) or an object (truthy).

s=>!!~(s+s).slice(1,-1).searchmatch(s)

Try it online!Try it online!

NB: Technically, \$s\$ is converted to a regular expression for match(), so the above title is a lie.

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!


Without a regular expression, 33 bytes

Returns a Boolean value.

s=>!!~(s+s).slice(1,-1).search(s)

Try it online!

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!


Without a regular expression,  33  29 bytes

Returns either null (falsy) or an object (truthy).

s=>(s+s).slice(1,-1).match(s)

Try it online!

NB: Technically, \$s\$ is converted to a regular expression for match(), so the above title is a lie.

added another version
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!


Without a regular expression, 33 bytes

Returns a Boolean value.

s=>!!~(s+s).slice(1,-1).search(s)

Try it online!

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!


Without a regular expression, 33 bytes

Returns a Boolean value.

s=>!!~(s+s).slice(1,-1).search(s)

Try it online!

Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 650

JavaScript (ES6), 22 bytes

Returns a Boolean value.

s=>/^(.*)\1+$/.test(s)

Try it online!