
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Arithmetic Operators
- C# - Assignment Operators
- C# - Relational Operators
- C# - Logical Operators
- C# - Bitwise Operators
- C# - Miscellaneous Operators
- C# - Operators Precedence
- C# Conditional Statements
- C# - Decision Making
- C# - If
- C# - If Else
- C# - Nested If
- C# - Switch
- C# - Nested Switch
- C# Control Statements
- C# - Loops
- C# - For Loop
- C# - While Loop
- C# - Do While Loop
- C# - Nested Loops
- C# - Break
- C# - Continue
- C# OOP & Data Handling
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
C# - Character Classes
A character class matches any one of a set of characters. The following table describes the character classes −
Character class | Description | Pattern | Matches |
---|---|---|---|
[character_group] | Matches any single character in character_group. By default, the match is case-sensitive. | [mn] | "m" in "mat" "m", "n" in "moon" |
[^character_group] | Negation: Matches any single character that is not in character_group. By default, characters incharacter_group are case-sensitive. | [^aei] | "v", "l" in "avail" |
[ first - last ] | Character range: Matches any single character in the range from first to last. | [b-d] | [b-d]irds Birds Cirds Dirds |
. | Wildcard: Matches any single character except \n. | a.e | "ave" in "have" "ate" in "mate" |
\p{ name } | Matches any single character in the Unicode general category or named block specified by name. | \p{Lu} | "C", "L" in "City Lights" |
\P{ name } | Matches any single character that is not in the Unicode general category or named block specified by name. | \P{Lu} | "i", "t", "y" in "City" |
\w | Matches any word character. | \w | "R", "o", "m" and "1" in "Room#1" |
\W | Matches any non-word character. | \W | "#" in "Room#1" |
\s | Matches any white-space character. | \w\s | "D " in "ID A1.3" |
\S | Matches any non-white-space character. | \s\S | " _" in "int __ctr" |
\d | Matches any decimal digit. | \d | "4" in "4 = IV" |
\D | Matches any character other than a decimal digit. | \D | " ", "=", " ", "I", "V" in "4 = IV" |
csharp_regular_expressions.htm
Advertisements