Problem 35. Quote Doubler
Given a string s1, find all occurrences of the single quote character and replace them with two occurrences of the single quote character.
If there are n such occurrences in s1, then s2 will be n characters longer than s1.
Solution Stats
Problem Comments
-
8 Comments
This problem description would benefit from an example of the kind of input that could be expected (as well as the correct output).
Based on the description, I thought that I had to replace the string 'o'clock' with the string 'o''clock' (so making it usable in MATLAB.). And no, I did not manage to create input like that.
Instead, you want to replace every single quote with a double quote EXCEPT for the start-and-end quotes.
So 'o''clock' ==> 'o''''clock'
an example would make it clearer
I am not getting it .... Its always showing wrong
so weird!!!
I've found no matter how many '''' I add, it will only show one additional.
My answers are coming correct in MATLAB 2017b but not on this site.
This question need to be stated clearly with a sample example.
s1 is not a string, but a character array.
Solution Comments
Show commentsProblem Recent Solvers3715
Suggested Problems
-
Find all elements less than 0 or greater than 10 and replace them with NaN
15764 Solvers
-
Check to see if a Sudoku Puzzle is Solved
337 Solvers
-
Find the sum of the elements in the "second" diagonal
1194 Solvers
-
934 Solvers
-
Determine the number of odd integers in a vector
811 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!