Skip to main content

Cours numéro 2 :

 

---
title:title: Perfectionnement des systèmes open source
author:author: Dw4rF
#class: invert
paginate:paginate: true
math:math: katex
header:header: <div hidden>Made for ESGI students only</div>
marp:marp: true
---
## 4. REGEX

### 4.1. Késaco ?

*
* *Reg*ular *Ex*pression
* Aide au parsing de fichier
* Simple ou complexe, dépendamment du besoin

---

## 4. REGEX

### 4.2. Bases de compréhension (AND)

*
* `[]` : Caractères (ou type)
* `{}` : Nombre de caractères

---

## 4. REGEX

### 4.3. Bases de compréhension (OR)

*
* `()` : """switch"""
* `|` : Séparateur

---

## 4. REGEX

### 4.4. Joker(s)

*
* `.` : N'importe quel caratère (sur **UN** caractère uniquement)
* `.*` : N'importe quel caratère, pas de limite de nombre
* `\` : Escape les caractères spéciaux

---

## 4. REGEX

### 4.5. Position

*
* `^` : Juste *après* le début de ligne
* `$` : Juste *avant* la fin de ligne

---

## 4. REGEX

### 4.5. Practice !

* 06.xx.xx.xx.xx
* 07.xx.xx.xx.xx
* 06-xx-xx-xx-xx
* 07-xx-xx-xx-xx

---

## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font>.xx.xx.xx.xx
* <font style=style="color:blue">07</font>.xx.xx.xx.xx
* <font style=style="color:blue">06</font>-xx-xx-xx-xx
* <font style=style="color:blue">07</font>-xx-xx-xx-xx

Regex : <div style=style="visibility: hidden">(<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)</div>

---
## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font>.xx.xx.xx.xx
* <font style=style="color:blue">07</font>.xx.xx.xx.xx
* <font style=style="color:blue">06</font>-xx-xx-xx-xx
* <font style=style="color:blue">07</font>-xx-xx-xx-xx

Regex : (<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)

---
## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font><font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx
* <font style=style="color:blue">07</font><font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx
* <font style=style="color:blue">06</font><font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx
* <font style=style="color:blue">07</font><font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx

Regex : (<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)<div style=style="visibility: hidden">(<font style=style="color:green">\\.</font>|<font style=style="color:green">-</font>)</div>

---
## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font><font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx
* <font style=style="color:blue">07</font><font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx<font style=style="color:green">.</font>xx
* <font style=style="color:blue">06</font><font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx
* <font style=style="color:blue">07</font><font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx<font style=style="color:green">-</font>xx

Regex : (<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)(<font style=style="color:green">\\.</font>|<font style=style="color:green">-</font>)

---
## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">07</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">06</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">07</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font>

Regex : (<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)(<font style=style="color:green">\\.</font>|<font style=style="color:green">-</font>)<div style=style="visibility: hidden">[<font style=style="color:red">0-9</font>]{<font style=style="color:red">2</font>}</div>

---
## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">07</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">06</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">07</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font>

Regex : (<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)(<font style=style="color:green">\\.</font>|<font style=style="color:green">-</font>)[<font style=style="color:red">0-9</font>]{<font style=style="color:red">2</font>}

---
## 4. REGEX

### 4.6. Practice ! - correction

*
*<font <font style=style="color:blue">06</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">07</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font><font style=style="color:green">.</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">06</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font>
* <font style=style="color:blue">07</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font><font style=style="color:green">-</font><font style=style="color:red">xx</font>

Regex : (<font style=style="color:blue">06</font>|<font style=style="color:blue">07</font>)(<font style=style="color:green">\\.</font>[<font style=style="color:red">0-9</font>]{<font style=style="color:red">2</font>}|<font style=style="color:green">-</font>[<font style=style="color:red">0-9</font>]{<font style=style="color:red">2</font>}){4}