How would I go about reversing one or multiple words within a string and not the whole string? For example, if my string was "this is a test sentence and a cool one" and I wanted to reverse only words with the letter C in them, how would I go about it? The output would look something like "this is a test ecnetnes and a looc one" I've tried splitting the words and then reversing them if they meet the condition, but it keeps reversing all the words. Any help would be greatly appreciated - thanks!
Aucun commentaire:
Enregistrer un commentaire