Ce script à pour vocation d'offir un test interactif sur l'usages des Expressions Regulière (Regular Expressions, regex, regexp) en Javascript et de demontrer comment editer le contenut d'une textarea sans avoirs recours aux propriétées contenteditable ou designmode.
The purpos of this script is to test interactivaly Regular Expressions (regex, regexp) in Javascript an to demonstrates how to edit the content of a textarea without the need of contenteditable or designmode features.

1. Ceci n'a rien a voirs avec les REGEX, mais pour travailler sur une chaines de caractères, il vous faudrat évidemment dabord pouvoir capturer cette chaine.
Donc si vous n'êtes pas familé avec le javascript et la précieuse fonction getElementById(), je vous invite à, dans un premier temps, consulter cette page ou vous constatrer qu'il est aisé de capturer le contenu d'une textarea en vue d'obtenire une chaines de charactère (string) traitable en javascript.
1. This has nothing to do with REGEX, but to work on a string, you obviously first need to capture this string.
So if you're unfamiliar with javascript and its precious function getElementById(), I advice you to, firs of all, have look on this page where you'll see that it'is quite easy to capture a textarea content in order to get a string to play with in javascript.

2. Si cette matiè ne vous pause pas de problèmes, ne perdez pas votre temps et rendez-vous directement à la page de démonstration sur les Expressions Regulière, ou trouverez quellques test ainsi que quellques explications sur ce qui ce passe.
2. If the previous topic is ok for you, don't loos your time and go to the Regular Expressions demo page, where you'll see some test you may do aswell as some explanations on what is going on.

De quoi a t'on besoins?

What do we need?

Pour effectuer un remplacement dans une chaine de caractères par l'usage des regex, nous n'aurrons besoins que de 3 fonctions JAVASCRIPT (toutes sont standards):

To make a replacement on a string by the use of regex, we'll only need 3 JAVASCRIPT functions in oreder to do so (both are standard):

  1. getElementById sur un objet document, comme nous l'avons vus ici. on a document object, as we have seen here.
  2. new Regexp qui cree un objet regex a partir d'un string et des flags.
    Ces flags sont en general 'g' pour goumand ou avide grindy (remplacer tout), et 'i' pour insensible a la case.
    which make the regex object from string and flags.
    Those flags usualy are 'g' standing for grindy (replace all), and 'i' wich stands for case insensitive.
  3. replace
    prend 2 arguments :
    1. un objet de type regex
    2. La cible: le string a utiliser pour remplacer ce que regex a voulu dire.
    replace renvoit evidemment la nouvelle version du string.
    it take 2 arguments :
    1. A regex object
    2. The target: the string we'll use to repleace by the meaning of regex.
    replace will obviously give us back the new string.

Get Firefox!license: gnu gplValid XHTML 1.0 TransitionalUne alternative pour vos services internet


Ce travail a été accomplits par Nathan Meurrens pour Cassiopea.
Utilisez le librement sous les conditions de la gpl (voirs le code source pour plus d'informations).
This stuff is from Nathan Meurrens for Cassiopea.
Feel free to use it under the terms of the gpl (see source code fo details).