Href hyperlink, how to escape double quotes " ?
31 ビュー (過去 30 日間)
古いコメントを表示
How can I escape double quotes when displaying a hyperlink in matlab?
Example:
I want to create a hyperlink to execute this command:
[cmd_status cmd_return] = system('explorer.exe /select, "C:\My folder\My file" ')
Without double quotes, the relevant hyperlink is:
disp('<a href="matlab:system(''explorer.exe /select, C:\My folder\My file'');">Click Here</a>')
However, nothing I tried ("", \", '", ...) worked (it has to be double quotes, windows CMD does not accept anything else)
Thank you
2 件のコメント
Walter Roberson
2022 年 6 月 20 日
編集済み: Walter Roberson
2022 年 6 月 21 日
try coding
"
in place of each double quote that is being escaped
採用された回答
Fangjun Jiang
2022 年 6 月 20 日
編集済み: Fangjun Jiang
2022 年 6 月 21 日
knowing
double('"')
char(34)
This leads to the following, which works out properly
disp('<a href="matlab:system([''explorer.exe /select, '',char(34),''c:\My Folder\My File'',char(34)] );">Click Here</a>')
5 件のコメント
Fangjun Jiang
2022 年 6 月 21 日
Ha! this works out
disp('<a href="matlab:system([''explorer.exe /select, '',char(34),''c:\My Folder\My File'',char(34)] );">Click Here</a>')
その他の回答 (1 件)
Jan
2022 年 6 月 21 日
編集済み: Jan
2022 年 6 月 22 日
I'm curious:
% [UNTESTED] [TYPO FIXED]
disp(['<a href="matlab:system(', ...
'strrep(''explorer.exe /select, $C:\My folder\My file$'', ''$'', char(34));">Click Here</a>')
Fanjung's idea:
% [UNTESTED]
disp('<a href="matlab:myExplorer(''C:\My folder\My file'');">Click Here</a>')
function myExplorer(File)
system(sprintf('explorer.exe /select, "%s"');
end
参考
カテゴリ
Help Center および File Exchange で Whos についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!