Solution

/* Solution to HackerRank: Balanced Strings
 * URL: https://www.hackerrank.com/contests/regular-expresso/challenges/balanced-strings
 */

"^(ab|ba)+$"
possible strings:

ababab
abba
babaab

but not:

a
bab
abbaaba