To find names that end with extensions, create a pattern that matches a period followed by letters by using the lettersPattern function. (You can build up a complex pattern by combining simple patterns in expressions. Such expressions can also include literal text, like "." in this example.)
pat = "." + lettersPattern
pat = pattern
Matching:
"." + lettersPattern
Return a logical array indicating which names end with extensions.
TF = endsWith(str,pat)
TF = 2×3 logical array
1 1 0
1 1 0
Display the matching names.
str(TF)
ans = 4×1 string
"abstract.docx"
"data-analysis.ppt"
"data.tar.gz"
"results.ptx"
Find the names with extensions that are exactly three letters long.
pat = "." + lettersPattern(3);
TF = endsWith(str,pat);
str(TF)
ans = 2×1 string
"data-analysis.ppt"
"results.ptx"
For a list of functions that create pattern objects, see pattern.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.