How do I get rid of double quotes in a Matlab cell?

无人久伴 提交于 2019-12-10 15:23:56

问题


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'

?


回答1:


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'


来源:https://stackoverflow.com/questions/13282113/how-do-i-get-rid-of-double-quotes-in-a-matlab-cell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!