Please explain how to understand special strings like '^(\w:)?\'
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Characters and Strings dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!