Skip to main content

Posts

Showing posts from July, 2012

Escape Sequences in C# .Net

C# defines the following character escape sequences: \'  - single quote, needed for character literals \"  - double quote, needed for string literals \\  - backslash \0  - Unicode character 0 \a  - Alert (character 7) \b  - Backspace (character 8) \f  - Form feed (character 12) \n  - New line (character 10) \r  - Carriage return (character 13) \t  - Horizontal tab (character 9) \v  - Vertical quote (character 11) \uxxxx  - Unicode escape sequence for character with hex value xxxx \xn[n][n][n]  - Unicode escape sequence for character with hex value nnnn (variable length version of \uxxxx) \Uxxxxxxxx  - Unicode escape sequence for character with hex value xxxxxxxx (for generating surrogates)

Regular Expressions essential

Character Classes If you browse through the Pattern class specification, you'll see tables summarizing the supported regular expression constructs. In the "Character Classes" section you'll find the following: Construct Description [abc] a, b, or c (simple class) [^abc] Any character except a, b, or c (negation) [a-zA-Z] a through z, or A through Z, inclusive (range) [a-d[m-p]] a through d, or m through p: [a-dm-p] (union) [a-z&&[def]] d, e, or f (intersection) [a-z&&[^bc]] a through z, except for b and c: [ad-z] (subtraction) [a-z&&[^m-p]] a through z, and not m through p: [a-lq-z] (subtraction) The left-hand column specifies the regular expression constructs, while the right-hand column describes the conditions under which each construct will match. Note:  The word "class" in the phrase "character class" does not refer to a .class file. In the context of regular expressions...