
- 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# - Quantifier
Quantifiers specify how many instances of the previous element (which can be a character, a group, or a character class) must be present in the input string for a match to occur.
Quantifier | Description | Pattern | Matches |
---|---|---|---|
* | Matches the previous element zero or more times. | \d*\.\d | ".0", "19.9", "219.9" |
+ | Matches the previous element one or more times. | "be+" | "bee" in "been", "be" in "bent" |
? | Matches the previous element zero or one time. | "rai?n" | "ran", "rain" |
{ n } | Matches the previous element exactly n times. | ",\d{3}" | ",043" in "1,043.6", ",876", ",543", and ",210" in "9,876,543,210" |
{ n ,} | Matches the previous element at least n times. | "\d{2,}" | "166", "29", "1930" |
{ n , m } | Matches the previous element at least n times, but no more than m times. | "\d{3,5}" | "166", "17668" "19302" in "193024" |
*? | Matches the previous element zero or more times, but as few times as possible. | \d*?\.\d | ".0", "19.9", "219.9" |
+? | Matches the previous element one or more times, but as few times as possible. | "be+?" | "be" in "been", "be" in "bent" |
?? | Matches the previous element zero or one time, but as few times as possible. | "rai??n" | "ran", "rain" |
{ n }? | Matches the preceding element exactly n times. | ",\d{3}?" | ",043" in "1,043.6", ",876", ",543", and ",210" in "9,876,543,210" |
{ n ,}? | Matches the previous element at least n times, but as few times as possible. | "\d{2,}?" | "166", "29", "1930" |
{ n , m }? | Matches the previous element between n and m times, but as few times as possible. | "\d{3,5}?" | "166", "17668" "193", "024" in "193024" |
csharp_regular_expressions.htm
Advertisements