

- 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
What are anchors in regular expressions in C#?
Anchors are constructs in regular expressions in C#. It allows a match to succeed or fail depending on the current position in the string. The following table lists the anchors.
Assertion | Description | Pattern | Matches |
---|---|---|---|
^ | The match must start at the beginning of the string or line | ^\d{3} | "567" in "567-777-" |
$ | The match must occur at the end of the string or before at the end of the line or string. | -\d{4}$ | "-2012" in "8-12-2012" |
\A | The match must occur at the start of the string. | \A\w{3} | "Code" in "Code-007-" |
\Z | The match must occur at the end of the string or before at the end of the string. | -\d{3}\Z | "-007" in "Bond-901-007" |
\z | The match must occur at the end of the string. | -\d{3}\z | "-333" in "-901-333" |
\G | The match must occur at the point where the previous match ended. | \\G\(\d\) | "(1)", "(3)", "(5)" in "(1)(3)(5)[7](9)" |
\b | The match must occur on a boundary between a \w(alphanumeric) and a \W(nonalphanumeric) character. | \w | "R", "o", "m" and "1" in "Room#1" |
\B | The match must not occur on a \b boundary. | \Bend\w*\b | "ends", "ender" in "end sends endure lender" |
- Related Questions & Answers
- What are regular expressions in C#
- What are regular expressions in JavaScript?
- How regular expression anchors work in Python?
- What are the properties of Regular expressions in TOC?
- What is Regular Expressions?
- What are the regular expressions to finite automata?
- What are the Rules of Regular Expressions in Compiler Design?
- What are negated character classes that are used in Python regular expressions?
- What are some basic examples of Python Regular Expressions?
- JavaScript Regular Expressions
- Java Regular Expressions Tutorial
- Pattern.matches() method in Java Regular Expressions
- Matcher.pattern() method in Java Regular Expressions
- Back references in Java regular expressions
- Regular Expressions syntax in Java Regex
Advertisements