The getPartOfString method must return the substring that begins with the character after the first space and ends with the end of the word
that follows the 4th space.
Example: "CodeGym is the best place to learn Java."
Result: "is the best place"
Example: "Amigo and Diego are best friends!"
Find a substring
- 24
Locked
Comments (7)
- Popular
- New
- Old
You must be signed in to leave a comment
matemate123
8 March, 05:57
Hint:
Most misleading in this task is "HARD" and "one star".
0
Jomar TayactacExpert
26 May 2022, 16:17
"\\s\\S+"
0
Adrian
2 March 2021, 18:40
This task does not want a "word" that follows the 4th whitespace, it wants the substring that follows it. or more generally, any character(s) that is not a whitespace.
"hello my name is ^&*%#" returning "my name is ^&*%#" will pass.
I wasted a lot of time on this because the two approaches I came up with (one using regex the other a for loop) would have thrown it an exception if the character after the 4th space was not a word character.
+3
Justin Smith
12 December 2021, 14:07
This appears to be true and CodeGym should clarify what they mean by a word, especially since there is a task in another lesson earlier that uses the regex definition of a word character and CodeGym doesn't explain that either.
0
ugabuga
2 January 2022, 07:59
I too wasted a lot of time thinking I have to discard any punctuation characters and other non alphanumericals after the last word.
CodeGym should clarify!!
0
matemate123
8 March, 05:49
When I start thinking second hours for what I forgot to prevent and go to discuss panel to find out that in this task logic is opposite :D
0
KIN SOCHEAT
18 April 2020, 03:52
don't use "\\W'' can pass only (" ").
0