
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Explain C# Substitution in regular expression
A regular expression is a pattern that could be matched against an input text. There are various categories of characters, operators, and constructs that let’s you to define regular expressions. Substitutions are used in replacement patterns.
The following table lists the substitutions.
Character | Description | Pattern | Replacement pattern | Input string | Resulting string |
---|---|---|---|---|---|
$number | Substitutes the substring matched by group number. | \b(\w+)(\s)(\w+)\b | $3$2$1 | "one two" | "two one" |
${name} | Substitutes the substring matched by the named groupname. | \b(?< word1>\w+)(\s)(?< word2>\w+)\b | ${word2} ${word1} | "one two" | "two one" |
$$ | Substitutes a literal "$". | \b(\d+)\s?USD | $$$1 | "103 USD" | "$103" |
$& | Substitutes a copy of the whole match. | (\$*(\d*(\.+\d+)?){1}) | **$& | "$1.30" | "**$1.30**" |
$` | Substitutes all the text of the input string before the match. | B+ | $` | "AABBCC" | "AAAACC" |
$' | Substitutes all the text of the input string after the match. | B+ | $' | "AABBCC" | "AACCCC" |
$+ | Substitutes the last group that was captured. | B+(C+) | $+ | "AABBCCDD" | AACCDD |
$_ | Substitutes the entire input string. | B+ | $_ | "AABBCC" | "AAAABBCCC |
- Related Questions & Answers
- Explain C# Quantifiers in regular expression
- Explain C# Grouping Constructs in regular expression
- Explain the concept of Regular expression.
- Explain Python regular expression search vs match
- Explain JavaScript Regular Expression modifiers with examples
- Explain the Star Height of Regular Expression and Regular Language
- Explain Regular Expression "\A" Metacharacter in Java
- Explain Regular Expression "\w" Metacharacter in Java
- Explain Regular Expression "\s" Metacharacter in Java
- Explain the Java regular expression construct "re?".
- Explain the relationship between Finite Automata and Regular Expression.
- Regular Expression in C# with Examples
- Explain the sub-expression "[...]" in Java Regular expressions
- Can you explain Python Regular Expression Syntax in a simple way?
- Explain Arden’s theorem to convert DFA to Regular Expression
Advertisements