| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>Regular expressions 6. Convenience escape sequences</title> |
| 3 | <style> |
| 4 | td { padding-left: 5pt; padding-right: 5pt; } |
| 5 | th { padding-left: 5pt; padding-right: 5pt; } |
| 6 | code { white-space: pre-wrap; } |
| 7 | dd { white-space: pre-wrap; } |
| 8 | </style> |
| 9 | </head><body bgcolor="#FFFFFF"> |
| 10 | |
| 11 | <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Palatino,Times" size=6 color="#999900"><b> |
| 12 | Regular expressions 6. Convenience escape sequences |
| 13 | </b></font></table></table> |
| 14 | <p>Convenience escape sequences in a <a href="Regular_expressions.html">regular expression</a> present a shorthand for some character classes.</p> |
| 15 | <dl> |
| 16 | <dt><b></b>\d matches a digit: [0-9]. |
| 17 | <dd> Example: "-?\d+" matches any integer.</dd> |
| 18 | <dt><b></b>\D <i>not</i> a digit: [^0-9]. |
| 19 | <dt><b></b>\l a letter: [a-zA-Z]. |
| 20 | <dt><b></b>\L <i>not</i> a letter: [^a-zA-Z]. |
| 21 | <dt><b></b>\s whitespace: [ \t\n\r\f\v]. |
| 22 | <dt><b></b>\S <i>not</i> whitespace: [^ \t\n\r\f\v]. |
| 23 | <dt><b></b>\w "word" character: [a-zA-Z0-9_]. |
| 24 | <dd> Example: "\w+" matches a "word", i.e., a string of one or more characters that may consist of letters, digits and underscores.</dd> |
| 25 | <dt><b></b>\W <i>not</i> a "word" character: [^a-zA-Z0-9_]. |
| 26 | <dt><b></b>\B any character that is <i>not</i> a word-delimiter. |
| 27 | </dl> |
| 28 | <h3>Links to this page</h3> |
| 29 | <ul> |
| 30 | <li><a href="Regular_expressions_1__Special_characters.html">Regular expressions 1. Special characters</a> |
| 31 | <li><a href="Regular_expressions_3__Anchors.html">Regular expressions 3. Anchors</a> |
| 32 | </ul> |
| 33 | <hr> |
| 34 | <address> |
| 35 | <p>© djmw 20010708</p> |
| 36 | </address> |
| 37 | </body> |
| 38 | </html> |