Note : Cet article a été publié à l’origine en 2009. Certaines étapes, commandes ou versions de logiciels ont pu changer. Consultez la documentation actuelle de Programming pour les informations les plus récentes.

Q: What are the special characters, escape sequences, and in general the syntax when doing regex (Regular Expressions)? A: . any character except a newline

d any decimal digit

D any non-digit

s any whitespace character

S any non-whitespace characte

w any alphanumeric character

W any non-alphanumeric character

number the contents of the group with the given number

  • zero or more of the preceding block

*? zero or more of the preceding block (non-greedy)

+ one or more of the preceding block

+? one or more of the preceding block (non-greedy)

+ zero or one of the preceding block

+? zero or one of the preceding block (non-greedy)

{m} exactly m copies of the preceding block

{m, n} m to n copies of the preceding block

{m, n}? m to n copies of the preceding block (no-greedy)

^ beginning of line

$ end of line

b word boundary

B non-word boundary

(…) group

(?:…) non-grouping group

(?=…) matches if <…> matches next, but does not consume the string

(?!…) matches if <…> does NOT match next, but does not consume the string

x|y matches x or y

matches any one of x, y or z

matches any character except x, y or z

matches any one character between a and z

matches any one character except the characters between a and z

Résumé

Articles Connexes