Effacer les filtres
Effacer les filtres

Is there a path in the string?

2 vues (au cours des 30 derniers jours)
Luca Re
Luca Re le 16 Juin 2023
Commenté : Mathieu NOE le 20 Juin 2023
hi,
a: example: f='\report\
b: example =f='c:\root\report\
how can i identify the string with case "a" or with "b"?
in the case 'a' i see a folder..
in case 'b' i see a path with folder
  5 commentaires
Luca Re
Luca Re le 19 Juin 2023
it seems too simple
Mathieu NOE
Mathieu NOE le 20 Juin 2023
why something simple could not be used ?

Connectez-vous pour commenter.

Réponses (1)

Fangjun Jiang
Fangjun Jiang le 16 Juin 2023
You can utilize the exist() function.
Assume you are at the c:\root folder, and there is a \report sub-folder
exist('\report','dir') will return 0
exist('c:\root\report','dir') will return 7, since 'c:\root\report' is the full path of a folder.
Please note, exist('report','dir') will also return 7.

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by