Check if a string is entirely made of the same substring

JavaScript (ES6), 22 bytes

Returns a Boolean value.


Try it online!

Without a regular expression,  33  29 bytes

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


Try it online!

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

Brachylog, 4 3 bytes


Try it online!


ġ=Ṁ    Implicit input, say "abcabc"
ġ      Split into chunks of equal lengths (except maybe the last one): ["abc","abc"]
 =     Apply the constraint that all of the chunks are equal,
  Ṁ    and that there are multiple of them.

The program prints true. if the constraints can be satisfied, and false. if not.

grep, 19

grep -qxE '(.+)\1+'


while read; do 
  <<<"$REPLY" grep -qxE '(.+)\1+' && t="true" || t="false"
  echo "$REPLY: $t"
done < infile 


aa: true
aaa: true
abcabcabc: true
aba: false
ababa: false
weqweqweqweqweqw: false