Where Learning is Pleasure

Jayaram Krishnaswamy

Subscribe to Jayaram Krishnaswamy: eMailAlertsEmail Alerts
Get Jayaram Krishnaswamy: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Blog Feed Post

Regular Expressions with C# Interactive

Yes, you can. However you have to reference the Regex class (System.Text.RegularExpressions) as shown in this image.

After this you can use its objects and you have intellisense to provide you help in coding.

The Syntax for using RegularExpressions is:

Match match = Regex.Match(InputStr, Pattern, RegexOptions)

You set up a pattern and you test your Pattern against the InputStr you set up to see if there is a match.

Let me shown a very simple example (the example is run in Interactive C# in Visual Studio Community 2017). Make sure you have already used using System.Text.RegularExpressions before executing these statements:

In the above, the InputStr is 'Jayaram' and the Pattern is shown above. You need to type each line and hit Enter. It is somewhat slow.
In the above case, a match was found for the first lower-case letter in the InputStr.

Here is another example:

The match is for the first upper-case letter in the string.

Here is an example for 2 adjacent numbers in the string:

Only one of the blocks there is a match. Same pattern but different InputStr.

Read the original blog entry...

More Stories By Jayaram Krishnaswamy

Jayaram Krishnaswamy is a technical writer, mostly writing articles that are related to the web and databases. He is the author of SQL Server Integration Services published by Packt Publishers in the UK. His book, 'Learn SQL Server Reporting Services 2008' was also published by Packt Publishers Inc, Birmingham. 3. "Microsoft SQL Azure Enterprise Application Development" (Dec 2010) was published by Packt Publishing Inc. 4. "Microsoft Visual Studio LightSwitch Business Application Development [Paperback] "(2011) was published by Packt Publishing Inc. 5. "Learning SQL Server Reporting Services 2012 [Paperback]" (June 2013) was Published by Packt Publishing Inc. Visit his blogs at: http://hodentek.blogspot.com http://hodentekHelp.blogspot.com http://hodnetekMSSS.blogspot.com http://hodnetekMobile.blogspot.com He writes articles on several topics to many sites.