Skip to main content
Commonmark migration
Source Link

#JavaScript (ES6), 25 bytes

JavaScript (ES6), 25 bytes

s=>/(.+?)\1*$/.exec(s)[1]

Try it online!

###Regular expression

Regular expression

   +-------> 1st (and only) capturing group: 1 or more character(s), non greedily
   |   +---> reference to the capturing group, repeated 0 to N times
  _|_  | +-> end of string
 /   \/ \|
/(.+?)\1*$/

#JavaScript (ES6), 25 bytes

s=>/(.+?)\1*$/.exec(s)[1]

Try it online!

###Regular expression

   +-------> 1st (and only) capturing group: 1 or more character(s), non greedily
   |   +---> reference to the capturing group, repeated 0 to N times
  _|_  | +-> end of string
 /   \/ \|
/(.+?)\1*$/

JavaScript (ES6), 25 bytes

s=>/(.+?)\1*$/.exec(s)[1]

Try it online!

Regular expression

   +-------> 1st (and only) capturing group: 1 or more character(s), non greedily
   |   +---> reference to the capturing group, repeated 0 to N times
  _|_  | +-> end of string
 /   \/ \|
/(.+?)\1*$/
added an explanation of the regex
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

#JavaScript (ES6), 25 bytes

  
s=>/(.+?)\1*$/.exec(s)[1]

Try it online!

###Regular expression

   +-------> 1st (and only) capturing group: 1 or more character(s), non greedily
   |   +---> reference to the capturing group, repeated 0 to N times
  _|_  | +-> end of string
 /   \/ \|
/(.+?)\1*$/

#JavaScript (ES6), 25 bytes

 
s=>/(.+?)\1*$/.exec(s)[1]

Try it online!

#JavaScript (ES6), 25 bytes

 
s=>/(.+?)\1*$/.exec(s)[1]

Try it online!

###Regular expression

   +-------> 1st (and only) capturing group: 1 or more character(s), non greedily
   |   +---> reference to the capturing group, repeated 0 to N times
  _|_  | +-> end of string
 /   \/ \|
/(.+?)\1*$/
Source Link
Arnauld
  • 197.7k
  • 20
  • 179
  • 650

#JavaScript (ES6), 25 bytes

s=>/(.+?)\1*$/.exec(s)[1]

Try it online!