What is Regular expression? (DotNet and C# Interview questions)
- By Shiv Prasad Koirala in .Net
- Dec 6th, 2014
- 35189
- 0
Regular expression is a pattern matching technique. Most of the data follow patterns, some examples of common data patterns are as shown in the below table :-
Email Address |
Email address data starts with some characters followed by "@" and then a "." and finally the domain extension. |
|
Phone number |
901-9090-909023 |
Phone number data starts with an international code followed by region code and then the phone number. |
By using regular expression you can represent these data patterns and utilize the same for validations and manipulation of data.
In order to use regular expression we need to create the object of "Regex" class and pass the pattern to Regex. For example the below pattern represent's data pattern of 10 character length which can be any small characters from a to z.
Once you have specified the pattern as described in the previous step you can then use the "IsMatch" function to check if the data matches with the pattern.
Note: - In some rare cases we have seen interviewers ask to write down regex patterns. So we would suggest to see the below youtube video "Explain Regex ?" which explains how to write any complex regular expression with ease.
Preparing for .NET and C# interview visit us at www.questpond.com
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more