🏠 Inicio
Pruebas de rendimiento
📊 Todos los benchmarks 🦖 Dinosaurio v1 🦖 Dinosaurio v2 ✅ Aplicaciones To-Do List 🎨 Páginas libres creativas 🎯 FSACB - Showcase definitivo 🌍 Benchmark de traducción
Modelos
🏆 Top 10 modelos 🆓 Modelos gratuitos 📋 Todos los modelos ⚙️ Kilo Code
Recursos
💬 Biblioteca de prompts 📖 Glosario de IA 🔗 Enlaces útiles
5

Thay thế nâng cao với Regex và Backreference

#regex #substitute #backreference #pattern

Sử dụng lệnh :substitute kết hợp với biểu thức chính quy và tham chiếu ngược để định dạng lại cấu trúc văn bản.

Một tệp văn bản chứa các đường dẫn URL cũ có định dạng 'http://old-site.com/category/id-title'. Hãy viết một lệnh :s để thay đổi cấu trúc thành 'https://new-site.net/id/title' cho toàn bộ tệp. Bạn cần sử dụng nhóm capture (parentheses trong regex) để trích xuất 'id' và 'title' và tham chiếu chúng trong phần thay thế (ví dụ: \1, \2).