« Regex » : différence entre les versions
De wiki_pcwiki2
Aller à la navigationAller à la recherche
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (6 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
KEYWORDS: REGEX, 19/12/2021 | KEYWORDS: REGEX, 19/12/2021 | ||
- pour tester des regex: https://regexr.com/ | - pour tester des regex: https://regex101.com/ ou https://regexr.com/ | ||
- dernier programme écrit avec des regex: test.109.regex sur la VM debian10-dvt | - dernier programme écrit avec des regex: '''/home/local/src/Atelier/pcLib/V9.87.tests.test.109.regex''' sur la VM debian10-dvt | ||
Exemple: | |||
[bB].*at.*:$ | |||
toute expression ayant un 'b' ou un 'B' suivi de n'importe quoi, | |||
puis 'at' suivi de n'importe quoi, | |||
et se finissant par un ':' | |||
''une'' '''bat'''''terie au plomb''''':''''--> ok | |||
''des'' '''Bat''''ailles''''':''' --> ok | |||
''une'' '''blat'''''te''''':''' -->ok | |||
'''Characters''' | |||
Escape character: \ | |||
Any character: . | |||
Digit: \d | |||
Not a digit: \D | |||
Word character: \w | |||
Not a word character: \W | |||
Whitespace: \s | |||
Not whitespace: \S | |||
Word boundary: \b | |||
Not a word boundary: \B | |||
Beginning of a string: ^ | |||
End of a string: $ | |||
'''Groupings''' | |||
Matches characters in brackets: [ ] | |||
Matches characters not in brackets: [^ ] | |||
Either or: | | |||
Capturing group: ( ) | |||
'''Quantifiers''' | |||
0 or more: * | |||
1 or more: + | |||
0 or 1: ? | |||
An exact number of characters: { } | |||
Range of number of characters: {Minimum, Maximum} | |||
Dernière version du 20 février 2022 à 09:29
KEYWORDS: REGEX, 19/12/2021
- pour tester des regex: https://regex101.com/ ou https://regexr.com/ - dernier programme écrit avec des regex: /home/local/src/Atelier/pcLib/V9.87.tests.test.109.regex sur la VM debian10-dvt
Exemple: [bB].*at.*:$ toute expression ayant un 'b' ou un 'B' suivi de n'importe quoi, puis 'at' suivi de n'importe quoi, et se finissant par un ':' une batterie au plomb:'--> ok des Bat'ailles: --> ok une blatte: -->ok Characters
Escape character: \ Any character: . Digit: \d Not a digit: \D Word character: \w Not a word character: \W Whitespace: \s Not whitespace: \S Word boundary: \b Not a word boundary: \B Beginning of a string: ^ End of a string: $
Groupings
Matches characters in brackets: [ ] Matches characters not in brackets: [^ ] Either or: | Capturing group: ( )
Quantifiers
0 or more: *
1 or more: +
0 or 1: ?
An exact number of characters: { }
Range of number of characters: {Minimum, Maximum}