Reputation: 2571
I have an array of cells in Matlab that all elements in the cell are expressed as:
'"something"'
How can I create an array of
'something'
?
Upvotes: 4
Views: 4725
Reputation: 1
This does not work for numbers
regexprep(string(67), '^"|"$', '')
ans =
"67"
Upvotes: 0
Reputation: 18560
Here are two solutions. strrep
removes all instances of double quotes, while regexprep
only removes double quotes at the start and end of the string (thanks to Gunther Struyf for pointing out that the second regexprep
solution would be needed in some scenarios):
>> A = {'"hello"', '"wor"ld"'}
A =
'"hello"' '"wor"ld"'
>> B = strrep(A, '"', '')
B =
'hello' 'world'
>> C = regexprep(A, '^"|"$', '')
C =
'hello' 'wor"ld'
Upvotes: 6