Regex

De wiki_pcwiki2
Aller à la navigationAller à la recherche

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}