Retourne la première sous-chaîne correspondant au motif
Syntaxe String reg.exec(String chaine)
Compatible tous navigateurs
Oui
Oui
Oui
Oui
Oui
Oui
Oui
Description Retourne la première sous-chaîne correspondant au motif.
Voir aussi la méthode test() de RegExp.
Exemple 1 : Extraction par exec()
Code source
<script type="text/javascript"> var reg=newRegExp("[0-9]+","g"); var chaine="Il y a 3600 secondes dans 1 heure"; document.write(chaine+"<BR>"); document.write(reg.exec(chaine));
</script>