<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Expressions_rationelles_en_Python</id>
	<title>Expressions rationelles en Python - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?action=history&amp;feed=atom&amp;title=Expressions_rationelles_en_Python"/>
	<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;action=history"/>
	<updated>2026-05-19T18:09:10Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;diff=549&amp;oldid=prev</id>
		<title>Jpinon le 11 février 2024 à 15:48</title>
		<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;diff=549&amp;oldid=prev"/>
		<updated>2024-02-11T15:48:41Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;fr&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Version précédente&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version du 11 février 2024 à 15:48&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Ligne 1 :&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Ligne 1 :&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Les &lt;/del&gt;Les expressions régulières sont quelque chose de merveilleux.   &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Les expressions régulières &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(rationelles en français ou regular expressions anglais) &lt;/ins&gt;sont quelque chose de merveilleux.   &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Modules utilisés ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Modules utilisés ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jpinon</name></author>
	</entry>
	<entry>
		<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;diff=250&amp;oldid=prev</id>
		<title>Jpinon : version 1</title>
		<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;diff=250&amp;oldid=prev"/>
		<updated>2023-09-20T15:56:18Z</updated>

		<summary type="html">&lt;p&gt;version 1&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;fr&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Version précédente&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Version du 20 septembre 2023 à 15:56&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Ligne 1 :&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Ligne 1 :&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Les Les expressions régulières sont quelque chose de merveilleux.  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Les Les expressions régulières sont quelque chose de merveilleux. &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Modules utilisés ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Modules utilisés ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jpinon</name></author>
	</entry>
	<entry>
		<id>https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;diff=249&amp;oldid=prev</id>
		<title>Jpinon : Page créée avec « Les Les expressions régulières sont quelque chose de merveilleux.   == Modules utilisés == Et oui contrairement à perl où les regexp sont incluse dans le langage dans python il faut utiliser un module. Bon je crois qu&#039;il est là par défaut.  on doit donc faire un :&lt;syntaxhighlight lang=&quot;python3&quot;&gt;  import re &lt;/syntaxhighlight&gt;pour pouvoir l&#039;utiliser.  == Utilisation ==  === Recherche === Pour faire une recherche dans une chaine:&lt;syntaxhighlight lang=&quot;python3... »</title>
		<link rel="alternate" type="text/html" href="https://knowledge.pinon-hebert.fr/mediawiki/index.php?title=Expressions_rationelles_en_Python&amp;diff=249&amp;oldid=prev"/>
		<updated>2023-09-20T15:51:59Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec « Les Les expressions régulières sont quelque chose de merveilleux.   == Modules utilisés == Et oui contrairement à perl où les regexp sont incluse dans le langage dans python il faut utiliser un module. Bon je crois qu&amp;#039;il est là par défaut.  on doit donc faire un :&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;  import re &amp;lt;/syntaxhighlight&amp;gt;pour pouvoir l&amp;#039;utiliser.  == Utilisation ==  === Recherche === Pour faire une recherche dans une chaine:&amp;lt;syntaxhighlight lang=&amp;quot;python3... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Les Les expressions régulières sont quelque chose de merveilleux. &lt;br /&gt;
&lt;br /&gt;
== Modules utilisés ==&lt;br /&gt;
Et oui contrairement à perl où les regexp sont incluse dans le langage dans python il faut utiliser un module. Bon je crois qu&amp;#039;il est là par défaut.&lt;br /&gt;
&lt;br /&gt;
on doit donc faire un :&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
 import re&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;pour pouvoir l&amp;#039;utiliser.&lt;br /&gt;
&lt;br /&gt;
== Utilisation ==&lt;br /&gt;
&lt;br /&gt;
=== Recherche ===&lt;br /&gt;
Pour faire une recherche dans une chaine:&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
#Teste si la chaine commence par &amp;quot;Les&amp;quot; et se termine par &amp;quot;duchesse&amp;quot;&lt;br /&gt;
&lt;br /&gt;
txt = &amp;quot;Les chausettes de l&amp;#039;archiduchesses&amp;quot;&lt;br /&gt;
x = re.search(&amp;quot;^Les.*duchesses$&amp;quot;, txt)&lt;br /&gt;
&lt;br /&gt;
if x:&lt;br /&gt;
  print(&amp;quot;OUI! Ca colle!&amp;quot;)&lt;br /&gt;
else:&lt;br /&gt;
  print(&amp;quot;Non&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remplacement ===&lt;br /&gt;
On peut remplacer classiquement un motif &amp;quot;regexp&amp;quot; par une chaine donnée:&amp;lt;syntaxhighlight lang=&amp;quot;python3&amp;quot;&amp;gt;&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
# Remplace les espaces par des &amp;quot;underscore&amp;quot;&lt;br /&gt;
&lt;br /&gt;
txt = &amp;quot;Les chausettes de l&amp;#039;archiduchesses&amp;quot;&lt;br /&gt;
x = re.sub(&amp;quot;\s&amp;quot;, &amp;quot;_&amp;quot;, txt)&lt;br /&gt;
print(x) &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;Vas nous donner :&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Les_chausettes_de_l&amp;#039;archiduchesses&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Les fonctions plus subtiles ===&lt;br /&gt;
&lt;br /&gt;
==== findall ====&lt;br /&gt;
Donne la liste de toutes les chaines correspondant au motif.&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
import re&lt;br /&gt;
&lt;br /&gt;
#Return a list containing every occurrence of &amp;quot;ai&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
txt = &amp;quot;Les chaussettes de l&amp;#039;archiduchesse sont-elles sèches? Archi-sèches ?&amp;quot;&lt;br /&gt;
x = re.findall(&amp;quot;.s+.&amp;quot;, txt)&lt;br /&gt;
print(x)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;On cherche la liste des chaînes du texte contenant un ou plusieurs &amp;quot;s&amp;quot; à la suite précédé et suivi d&amp;#039;un caractère quelconque.?&lt;br /&gt;
&lt;br /&gt;
Ça nous donne:&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
[&amp;#039;es &amp;#039;, &amp;#039;usse&amp;#039;, &amp;#039;es &amp;#039;, &amp;#039;esse&amp;#039;, &amp;#039; so&amp;#039;, &amp;#039;es &amp;#039;, &amp;#039;es?&amp;#039;, &amp;#039;-sè&amp;#039;, &amp;#039;es &amp;#039;]&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jpinon</name></author>
	</entry>
</feed>