I'm doing string handling on delphhi in school right now, and there is a challenge to softcode a way to find the last word, im stuck. Do you know how i would do this?
If it's a sentence then every word has a space at the end of it except the last word. So I would keep (loop) through a sentence finding the position of the space and deleting up until that space until I couldnt do it anymore. Then I should be left with the last word. (You may have to delete the last character if it has a full stop). sSen := //inputted sentence while pos(' ', sSen) 0 do begin Delete( sSen, 1, pos(' ', sSen) ; end ; //sSen will be left with last word
Mr Gibson is the it teacher at my school and he helps us with cat 😀
Mr Gibson was my computer teacher too.
Mr Long I love you
I'm doing string handling on delphhi in school right now, and there is a challenge to softcode a way to find the last word, im stuck. Do you know how i would do this?
If it's a sentence then every word has a space at the end of it except the last word. So I would keep (loop) through a sentence finding the position of the space and deleting up until that space until I couldnt do it anymore. Then I should be left with the last word. (You may have to delete the last character if it has a full stop).
sSen := //inputted sentence
while pos(' ', sSen) 0 do
begin
Delete( sSen, 1, pos(' ', sSen) ;
end ;
//sSen will be left with last word