Check if a string is entirely made of the same substring

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.


Brachylog, 4 3 bytes

ġ=Ṁ

Try it online!

Explanation

ġ=Ṁ    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+'

Test

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

Output:

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