Function for sanitizing field name strings
11 ビュー (過去 30 日間)
古いコメントを表示
We have a file parser function (Midas BLUE) that generates structure arrays for some of the keyword/value pairs that can occur. The existing code uses deblank() to get rid of trailing strings, but the code bombs when the keyword contains a period(.) for instance. Is there a function that is similar to what readtable() uses to parse out field names to always return a valid name?
0 件のコメント
採用された回答
Rik
2023 年 8 月 25 日
s = 'name with spaces and a . in the middle';
matlab.lang.makeValidName(s)
2 件のコメント
Rik
2023 年 8 月 25 日
I believe a function like this has existed in the Matlab code base since the introduction of jsondecode, although I'm not entirely positive on that point.
I don't know if I would have expected this function to show up with that search term, but I understand your point. Discoverability of functions is sometimes the hardest part of a programming language.
At least I could help this time, and perhaps now it will show up in google results with similar search terms.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で String Parsing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!