Navigation: Macro > Instructions > Entrée/sortie générale > REGEX |
![]() ![]() ![]() ![]() |
REGEX Pattern$,Text$;Status,From1,To1,[From2,To2],... |
Cette fonction permet une recherche dans une chaîne de caractères à l'aide d'une expression régulière.
Expressions régulières (Norme POSIX 1002.3)
Resumé:
^ Début de la ligne
$ Fin de ligne
n? Zéro ou une occurrence du caractère 'n'
n* Zéro ou plus occurrences du caractère 'n'
n+ Au moins une ou plus occurrences du caractère 'n'
n{2} Exactement deux occurrences du caractère 'n'
n{2,} Au moins deux ou plus occurrences du caractère 'n'
n{2,4} Au moins 2 mais maximum 4 occurrences du caractère 'n' .
Tous les caractères
() Les parenthèses permettent de grouper les expressions (.*) Zéro ou plus occurrences de tous les caractères (n|a) Les deux caractères 'n' ou 'a' [1-6] Un nombre compris entre 1 et 6 [c-h] Une lettre minuscule entre 'c' et 'h' [D-M] Une lettre majuscule entre 'D' et 'M' [^a-z] Un caractère sauf une lettre minuscule entre 'a' et 'z' Pitfall: the ^ symbol only acts as an EXCEPT rule if it is the very first character inside a range, and it denies the entire range including the ^ symbol itself if it appears again later in the range. Also remember that if it is the first character in the entire expression, it means "start of line".
In any other place, it is always treated as a regular ^ symbol.
In other words, you cannot deny a word with ^undesired_word or a group with ^(undesired_phrase).
Read more detailed regex documentation to find out what is necessary to achieve this.
[_4^a-zA-Z] Any single character which can be the underscore or the number 4 or the ^ symbol or any letter, lower or upper case ?, +, * and the {} count parameters can be appended not only to a single character, but also to a group() or a range[].
therefore, ^.{2}[a-z]{1,2}_?[0-9]*([1-6]|[a-f])[^1-9]{2}a+$ would mean:
^.{2} = A line beginning with any two characters, [a-z]{1,2} = followed by either 1 or 2 lower case letters, _? = followed by an optional underscore, [0-9]* = followed by zero or more digits, ([1-6]|[a-f]) = followed by either a digit between 1 and 6 OR a lower case letter between a an d f, [^1-9]{2} = followed by any two characters except digits between 1 and 9 (0 is possible), a+$ = followed by at least one or more occurrences of 'a' at the end of a line.
Paramètres d'entrée
Pattern$ |
: |
Expression régulière de la recherche (pattern) |
Text$ |
: |
Texte ou rechercher |
Paramètres de sortie
Status |
: |
|
|
|
0 = Success. |
|
|
1 = Didn't find a match (for regexec). |
|
|
2 = Invalid pattern. |
|
|
3 = Pas implémenté. |
|
|
4 = Invalid character class name. |
|
|
5 = Trailing backslash. |
|
|
6 = Invalid back reference. |
|
|
7 = Unmatched left bracket. |
|
|
8 = Parenthesis imbalance. |
|
|
9 = Unmatched \{. |
|
|
10 = Invalid contents of \{\}. |
|
|
11 = Invalid range end. |
|
|
12 = Ran out of memory. |
|
|
13 = No preceding re for repetition op. |
|
|
14 = Premature end. |
|
|
15 = Compiled pattern bigger than 2^16 bytes. |
|
|
16 = Unmatched ) or \); not returned from regcomp. |
From |
: |
|
To |
: |
|