Introduction
When you are given a boring text, you just want to get it over with as quick as possible. Let's observe the following text:
Ens colligi timenda etc priorem judicem. De quascunque ii at contingere
repugnaret explicetur intellectu. Adjuvetis hoc fortassis suspicari opportune
obversari vix eam? Dei praemia prudens hominum iii constet requiri haberem. Ima
sane nemo modi fuit lus pro dem haud. Vestro age negare tactum hoc cui lor. Ne et
ut quod id soli soni deus. At constare innumera is occurret ea. Nia calebat seu
acquiro fraudem effingo dicimus.
Note: This text has newlines for readability, while the test cases you need to handle don't have newline characters.
One way to skim text is to find questions that the writer has put into the text. For example, there is 1 question in the text above. Namely:
Adjuvetis hoc fortassis suspicari opportune obversari vix eam?
This can be done by splitting the text into sentences. A sentence will always end with one of the following punctuation symbols: .?!
(others don't have to be handled). Other symbols than these are part of the sentence.
The Task
Given a line of text consisting of only
- letters (A-Za-z)
- numbers (0-9)
- spaces
- punctuation (
,.;:?!
) (a sentence cannot start with one of these).
Output the questions that are in the text in any reasonable format. You may assume that the text will always have at least 1 question. Outputting trailing and leading spaces before and after a question is allowed.
Important: Next to a punctuation symbol, there will never be another punctuation symbol (e.g. ??
is invalid and will not be required to handle).
Test cases
In the format:
Input
Output(s)
The test cases:
Huh? I haven't heard what you just said. Could you repeat that please?
Huh?
Could you repeat that please?
plz can i haz cheesburgr? i am cat pls.
plz can i haz cheesburgr?
This is a badly formatted question.Can u please help me,or my friends,with formatting this question ?thankyou.
Can u please help me,or my friends,with formatting this question ?
a.b.c.d?
d?
Does this question have a question mark? yes
Does this question have a question mark?
Why example.com resolves to 127.0.0.1 in 99.9 percent of cases?
9 percent of cases?
A? b? c? d!
A?
b?
c?
This is code-golf, so the submission with the lowest number of bytes wins!
.?!
Others must not be handled, as your rules specify, but you have said others don't have to be handled. \$\endgroup\$