Information générale
Catégorie:
Codage, syntaxe et commandes
The pattern works as follows:
\[ indicates you are matching an opening bracket. The \ is an escape character to indicate the next character is literal, as brackets are special characters in regular expressions.
([1-9]) indicates that you will be matching any character between 1-9. The parenthesis indicate a group, which is kept separate from the whole match and which we need later for the replace. The brackets are used to indicate that any of the contained characters can be a match, in this case the range 1-9.
- just matches the literal -.
\d in my pattern matches a single numeric digit.
The replace function replaces anything that matches the entire pattern with the second parameter. The $ followed by a digit indicates the group to be used there. So $1 indicates to use the match found in the first group, and $2 uses the match from the second group.
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement