I got stuck on this idea: how do I get the second longest word in a sentence ? I’m going to use it for an exit route in my code where the longest word might fail a test. Any ideas ? Thanks in advance.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
something like this:
This is a pretty naive definition of word however, since it only splits on whitespace so any punctuation will be included as part of the words. You may want to filter the sentence to remove punctuation characters first.