Ad space (banner)
๐Ÿ”ทVB.NET Lessons
Lesson 32 / 68

An introduction to regular expressions (pattern matching)

This lesson covers the basics of pattern matching with regular expressions in VB.NET, with the aim of checking whether a string fits a fixed format.

A regular expression is a special notation describing the pattern of a string. Regex.Match() extracts the part that matches and Regex.IsMatch() tests whether it matches at all.

The sample code extracts something phone-number-shaped with Regex.Match() and tests whether "12345" is all digits with Regex.IsMatch(). The d stands for a single digit.

A common early stumble is remembering what the symbols mean. There are many of them — d, ^, $ — and picking up the common patterns first is the way in.

In professional work, regular expressions are used widely for validating and extracting text — checking the format of an email address or a phone number, pulling particular information out of a log file.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run VB.NET directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)