35 lines
1.2 KiB
Markdown
35 lines
1.2 KiB
Markdown
# StrMatch
| |||
| |||
Modulo de una funcion unica de pattern matching para strings. Permite comparar un string contra un patrón con caracteres especiales.
| |||
| |||
## Uso
| |||
```cpp
| |||
CSimpleStringMatch::SimpleMatchInString("hello.png", "*.png"); // true
| |||
```
| |||
| |||
## Patrones soportados
| |||
| |||
| Carácter | Significado | Ejemplo |
| |||
|---|---|---|
| |||
| `*` | Cualquier secuencia de caracteres | `*.png` = cualquier archivo .png |
| |||
| `?` | Exactamente un carácter cualquiera | `?.txt` = a.txt, b.txt |
| |||
| `^` | Exactamente un dígito (0-9) | `file^.csv` = file1.csv |
| |||
| |||
Los patrones se pueden combinar libremente.
| |||
| |||
## Ejemplos
| |||
```cpp
| |||
SimpleMatchInString("hello_word.png", "*.png"); // true
| |||
SimpleMatchInString("hello_word.png", ".png*"); // false
| |||
SimpleMatchInString("aksdgello", "????gello"); // true
| |||
SimpleMatchInString("123a", "*^^^a"); // false
| |||
SimpleMatchInString("file123.txt", "file^^^.txt"); // true
| |||
SimpleMatchInString("anything", "*"); // true
| |||
SimpleMatchInString("", "*"); // true
| |||
SimpleMatchInString("abc", "??"); // false
| |||
```
| |||
| |||
## Notas
| |||
| |||
- `**` no está soportado como patrón válido. El carácter después de `*` actúa como finalizador de la secuencia.
| |||
- El patrón `*` solo equivale a "cualquier cosa" cuando está solo.
|