You are given a string and two characters. You have to print the string between these characters from the string.
Input
Input will first contain a string (not empty or null
). In the next line, there will be two characters separated by a space.
Challenge
Return the string between the two characters
Example
Hello! What's your name?
! ?
should result in the output:
" What's your name"
Rules
- The string will not be longer than 100 characters and will only contain ASCII characters in range
(space) to
~
(tilde) (character codes 0x20 to 0x7E, inclusive). See ASCII table for reference. - You must take input from the
stdin
( or closest alternative ). - The output should be surrounded with quotes(
"
). - You can write a full program, or a function which takes input, and outputs the final string
- The two characters will only contain ASCII characters in range
(space) to
~
(tilde) (character codes 0x20 to 0x7E, inclusive). See ASCII table for reference. - There is no guarantee that both the characters will be in the string.
- If any of the characters is not found in the string, print
"null"
. - If any of the characters is found more than one times (unless both the characters are same) in a string, print
"null"
. - If both the characters are the same character, print the string
"null"
.
Test Cases
1)
<HTML>code</HTML>
> < --> "null"
2)
What's what?
' ' --> "null"
3)
abcdefghijklmnopqrstuvwxyz
n k --> "lm"
4)
Testing...
e T --> ""
5)
Last test-case
- --> "test"
Scoring
This is code golf, so the shortest submission (in bytes) wins.
"
? Should we just surround it with another pair of quotes and not care about that? \$\endgroup\$one"two-three \n" -
output:"two"
(\n
is a newline) \$\endgroup\$