« Programmation PHP/Expressions rationnelles » : différence entre les versions

+ intro
m (<source> -> <syntaxhighlight> (phab:T237267))
(+ intro)
<noinclude>{{Programmation PHP}}</noinclude>
 
{{Programmation/Regex}}
 
En PHP, la validation d'une chaîne de caractères peut se faire en utilisant la fonction <code>preg_match</code> :
<syntaxhighlight lang="php">
<?php
$chaine = '12345'; // ou '12ABC'
 
if (preg_match('`[0-9]+`', $chaine)) {
print('Le texte est un entier positif');
} else {
print('Le texte n\'est pas un entier positif');
}
?>
</syntaxhighlight>
 
== Syntaxe ==