4 added 44 characters in body
source | link

Retina, 67 64 58 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])|¶(.)
$2$1$3$5$4$6$7¶

-9 bytes thanks to @Neil removing the three unnecessary ? I had added, as well as the unnecessary (.*) in the else-case.

Try it online or verify all test cases. (NOTE: Outputs with a trailing newline. The header in the test suite is to test each input-line as a separate test case, and the headerfooter is to remove that trailing newline for a more compact output.)

Explanation:

Prepend a new-linenewline before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else areis three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift the newline once towards the right for the next 'iteration':

¶(.)
$1¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

Retina, 67 64 58 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])|¶(.)
$2$1$3$5$4$6$7¶

-9 bytes thanks to @Neil removing the three unnecessary ? I had added, as well as the unnecessary (.*) in the else-case.

Try it online or verify all test cases. (NOTE: Outputs with a trailing newline. The header in the test suite is to test each input-line as a separate test case, and the header is to remove that trailing newline for a more compact output.)

Explanation:

Prepend a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift the newline once towards the right for the next 'iteration':

¶(.)
$1¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

Retina, 67 64 58 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])|¶(.)
$2$1$3$5$4$6$7¶

-9 bytes thanks to @Neil removing the three unnecessary ? I had added, as well as the unnecessary (.*) in the else-case.

Try it online or verify all test cases. (NOTE: Outputs with a trailing newline. The header in the test suite is to test each input-line as a separate test case, and the footer is to remove that trailing newline for a more compact output.)

Explanation:

Prepend a newline before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else is three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift the newline once towards the right for the next 'iteration':

¶(.)
$1¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

3 added 44 characters in body
source | link

RetinaRetina, 67 6464 58 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])|(.*)(.)
$2$1$3$5$4$6$7$8¶$2$1$3$5$4$6$7¶

-39 bytes thanks to @Neil removing the three unnecessary ? I had added, as well as the unnecessary (.*) in the else-case.

Try it onlineTry it online or verify all test casesverify all test cases. (NOTE: Outputs with a trailing newline. The header in the test suite is to test each input-line as a separate test case, and the header is to remove that trailing newline for a more compact output.)

Explanation:

AppendPrepend a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift the newline once towards the right so we can checkfor the next character'iteration':

(.*)¶(.)
$1$2¶$1¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

Retina, 67 64 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])|(.*)(.)
$2$1$3$5$4$6$7$8¶

-3 bytes thanks to @Neil removing the three unnecessary ? I had added.

Try it online or verify all test cases.

Explanation:

Append a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift newline once towards the right so we can check the next character:

(.*)¶(.)
$1$2¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

Retina, 67 64 58 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])(.)
$2$1$3$5$4$6$7¶

-9 bytes thanks to @Neil removing the three unnecessary ? I had added, as well as the unnecessary (.*) in the else-case.

Try it online or verify all test cases. (NOTE: Outputs with a trailing newline. The header in the test suite is to test each input-line as a separate test case, and the header is to remove that trailing newline for a more compact output.)

Explanation:

Prepend a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift the newline once towards the right for the next 'iteration':

¶(.)
$1¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

2 added 75 characters in body
source | link

Retina, 6767 64 bytes

^
¶
+`(.*?)(.?)¶([a-z])|(.?)(.*)¶([A-Z])|(.*)¶(.)
$2$1$3$5$4$6$7$8¶

Try it online-3 bytes thanks to @Neil removing the three unnecessary ? I had added.

Try it online or verify all test casesverify all test cases.

Explanation:

Append a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*?)(.?)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.?)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift newline once towards the right so we can check the next character:

(.*)¶(.)
$1$2¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

Retina, 67 bytes

^
¶
+`(.*?)(.?)¶([a-z])|(.?)(.*)¶([A-Z])|(.*)¶(.)
$2$1$3$5$4$6$7$8¶

Try it online or verify all test cases.

Explanation:

Append a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*?)(.?)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.?)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift newline once towards the right so we can check the next character:

(.*)¶(.)
$1$2¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

Retina, 67 64 bytes

^
¶
+`(.*)(.)¶([a-z])|(.)(.*)¶([A-Z])|(.*)¶(.)
$2$1$3$5$4$6$7$8¶

-3 bytes thanks to @Neil removing the three unnecessary ? I had added.

Try it online or verify all test cases.

Explanation:

Append a new-line before the input:

^
¶

Continue replacing as long as we can find a match:

+`

Everything else are three different checks merged together:

If the character right after the newline is lowercase letter: rotate everything before the newline once towards the right, and then append that character and the newline:

(.*)(.)¶([a-z])
$2$1$3¶

If the character right after the newline is an uppercase letter: rotate everything before the newline once towards the left, and then append that character and the newline:

(.)(.*)¶([A-Z])
$2$1$3¶

Else (neither a lowercase nor uppercase letter): simply shift newline once towards the right so we can check the next character:

(.*)¶(.)
$1$2¶

These three checks above are merged with regex OR statements (|) and larger group-replacements to make it act like an if(lowercase) ... elseif(uppercase) ... else ...:

1
source | link