Skip to main content
Commonmark migration
Source Link

#Carrot, 16 21 bytes

Carrot, 16 21 bytes

$^//^.*?(?=\d*$)/S0^#

Try it online! (input is linefeed separated)

###Explanation

Explanation

$^                Set the stack-string to be equal to the first line in the input
/                 Set the stack-array to be equal to the matches of this regex:
 /^.*?(?=\d*$)/   The beginning of the string followed by non-digit characters at the end that are not included in the match.
S0                Convert to a string with 0 as the delimiter
^#                Append the rest of the input to the stack-string

I had to increase the bytecount by 5 because the code did not work for testcases like a5b3 with multiple digits.

#Carrot, 16 21 bytes

$^//^.*?(?=\d*$)/S0^#

Try it online! (input is linefeed separated)

###Explanation

$^                Set the stack-string to be equal to the first line in the input
/                 Set the stack-array to be equal to the matches of this regex:
 /^.*?(?=\d*$)/   The beginning of the string followed by non-digit characters at the end that are not included in the match.
S0                Convert to a string with 0 as the delimiter
^#                Append the rest of the input to the stack-string

I had to increase the bytecount by 5 because the code did not work for testcases like a5b3 with multiple digits.

Carrot, 16 21 bytes

$^//^.*?(?=\d*$)/S0^#

Try it online! (input is linefeed separated)

Explanation

$^                Set the stack-string to be equal to the first line in the input
/                 Set the stack-array to be equal to the matches of this regex:
 /^.*?(?=\d*$)/   The beginning of the string followed by non-digit characters at the end that are not included in the match.
S0                Convert to a string with 0 as the delimiter
^#                Append the rest of the input to the stack-string

I had to increase the bytecount by 5 because the code did not work for testcases like a5b3 with multiple digits.

added 595 characters in body
Source Link
user41805
  • 13.2k
  • 6
  • 42
  • 88

#Carrot, 1616 21 bytes

$^//^[^\d]*^.*?(?=\d*$)/S0^#

Try it online! (input is linefeed separated)

###Explanation

$^                Set the stack-string to be equal to the first line in the input
/                 Set the stack-array to be equal to the matches of this regex:
 /^.*?(?=\d*$)/   The beginning of the string followed by non-digit characters at the end that are not included in the match.
S0                Convert to a string with 0 as the delimiter
^#                Append the rest of the input to the stack-string

I had to increase the bytecount by 5 because the code did not work for testcases like a5b3 with multiple digits.

#Carrot, 16 bytes

$^//^[^\d]*/S0^#

Try it online! (input is linefeed separated)

#Carrot, 16 21 bytes

$^//^.*?(?=\d*$)/S0^#

Try it online! (input is linefeed separated)

###Explanation

$^                Set the stack-string to be equal to the first line in the input
/                 Set the stack-array to be equal to the matches of this regex:
 /^.*?(?=\d*$)/   The beginning of the string followed by non-digit characters at the end that are not included in the match.
S0                Convert to a string with 0 as the delimiter
^#                Append the rest of the input to the stack-string

I had to increase the bytecount by 5 because the code did not work for testcases like a5b3 with multiple digits.

Source Link
user41805
  • 13.2k
  • 6
  • 42
  • 88

#Carrot, 16 bytes

$^//^[^\d]*/S0^#

Try it online! (input is linefeed separated)