Please explain how to understand special strings like '^(\w:)?\'
Mostrar comentarios más antiguos
I am trying to understand some m-files I find on this forum, but am stumped a bit by some of the strings statements used. Below are a few snippets that come from deploypcode by Sven.
Example 1:
function inPath = getFullPathStr(inPath)
% Tricky little function that returns the fully qualified path by looking for filesep
inPath = fullfile(inPath);
if ~any(regexp(inPath,['^(\w:)?\' filesep]))
inPath = fullfile(pwd, inPath);
end
end
Example 2:
mustIgnoreList = {'^\.$','^\.\.$',[mfilename '.m']};
tmp = {'\.dll$'}
My questions
- Why is fullfile not sufficient to get the full file path, why does Sven need to check with the following regexp function?
- How do I interpret '^(\w:)?\' ?
- In example 2, how do I interpret {'^\.$','^\.\.$',[mfilename '.m']} ? I understand he is concatenating chars, but what does the '^\.$' mean exactly?
- In {'\.dll$'}, what does the ending with a $ imply?
Thanks
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Characters and Strings en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!