Input:
A string only containing the following characters:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.?!
(space at the end) and two special characters (_
and |
)
Output:
Mirror the text based on the position(s) of the _
and |
.
_
mirrors horizontally and |
mirrors vertically.
Mirroring process
- The first
_
indicates the start of the mirroring of that substring, the second_
the end. - If just one
_
is present, you can continue on until the end of the string. - If more then two
_
are present, the same process repeats. - There can only be one
|
in the string, and this reversed the first substring and removes the second substring.
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.?!
(space at the end) will be converted to ɐqɔpǝɟɓɥıɾʞlɯuodbɹsʇnʌʍxʎz∀𐐒ƆᗡƎℲ⅁HIſ⋊⅂WNOԀΌᴚS⊥∩ΛMX⅄Z0⇂ᘔƐ߈ϛ9ㄥ86˙¿¡
(space at the end) when it is mirrored by _
(click the link for the unicode values - requires unicode v8.0+).
Example input 1: _Will I be mirrored?!
Output 1: Mıll I qǝ ɯıɹɹoɹǝp¿¡
Example input 2: Wi_ll I be mi_rrored?!
Output 2: Will I qǝ ɯırrored?!
When it is mirrored by |
we simply reverse the substring from 0 to index-of-|
.
Example input 1: Will I be mirror|ed?!
Output 1: Will I be mirrorrorrim eb I lliW
Both mirrors (_
and |
) can be present in the string.
General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
Test cases:
_Will I be mirrored?! -> Mıll I qǝ ɯıɹɹoɹǝp¿¡
Wi_ll I be mi_rrored?! -> Will I qǝ ɯırrored?!
Will I be mirror|ed?! -> Will I be mirrorrorrim eb I lliW
This_ is a test_ cont_aining bo|t_h mirrors. -> This ıs ɐ ʇǝsʇ contɐıuıuɓ qooq ɓuıuıɐtnoc ʇsǝʇ ɐ sı sihT
0_1_2_3_4_5|_6_7_8_9 -> 0⇂2Ɛ4ϛϛ4Ɛ2⇂0