Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Checking Birthday By Regular Expression
WhatsApp
Kailash Chandra Behera
6y
14.5
k
0
2
25
Blog
Introduction
The example tries to match birthdays to a regular expression. For demonstration purposes, the expression matches only birthdays that do not occur in April and that belong to people whose names begin with
"k"
.
// create regular expression
Regex expression =
new
Regex(@
"K.*\d[0-35-9]-\d\d-\d\d"
);
string
string1 =
"Kanhu's Birthday is 05-12-75\n"
+
"Panchanan's Birthday is 11-04-68\n"
+
"Suraj's Birthday is 04-28-73\n"
+
"Kailash's Birthday is 12-17-77"
;
// match regular expression to string and
// print out all matches
foreach
(Match myMatch
in
expression.Matches(string1))
Console.WriteLine(myMatch);
Console.ReadLine();
Output
Checking Birthday By Regular Expression
People also reading
Membership not found