Refer to the character ' in a string
6 views (last 30 days)
Show older comments
Edward on 31 Mar 2013
Commented: Steven Lord on 25 Jan 2023
Hi, i'm trying to write an algorithm to remove the character ' from a string, say for example: string='you're';
where I want to remove the ' to make the string 'youre' I get errors when I try to refer to a character as ''' though,
is there something I'm missing?
Steven Lord on 25 Jan 2023
This wasn't an option when the question was originally asked, but if you're using string arrays you don't need to double up the single quotes.
s = "you're"
t1 = strrep(s, "'", "")
t2 = erase(s, "'")
t3 = replace(s, "'", "")
string(string == '''') = '';
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!