Skip to main content

Cours numéro 2 :

---
title: Perfectionnement des systèmes open source
author: Dw4rF
#class: invert
paginate: true
math: katex
header: <div hidden>Made for ESGI students only</div>
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 style="color:blue">06</font>.xx.xx.xx.xx
* <font style="color:blue">07</font>.xx.xx.xx.xx
* <font style="color:blue">06</font>-xx-xx-xx-xx
* <font style="color:blue">07</font>-xx-xx-xx-xx

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

---
## 4. REGEX

### 4.6. Practice ! - correction

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

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

---
## 4. REGEX

### 4.6. Practice ! - correction

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

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

---
## 4. REGEX

### 4.6. Practice ! - correction

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

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

---
## 4. REGEX

### 4.6. Practice ! - correction

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

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

---
## 4. REGEX

### 4.6. Practice ! - correction

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

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

---
## 4. REGEX

### 4.6. Practice ! - correction

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

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