سلام بر برنامه نویسان عزیز 😉 در این مطلب از وب سایت پروگرم 98 کد Regex:چک کردن وجود چند حرف در چندین کلمه (k یا f در کلمات وجود داشته باشد) در c#.net را آماده کردم. انشاالله که این آموزش برای شما مفید باشد.
خروجی این کد به صورت زیر می باشد:
Matching words that contain 'k' or 'f'
using the following regular expression: \S*[kf]\S*
knife
knock
five
using the following regular expression: \S*[kf]\S*
knife
knock
five
کد Regex:چک کردن وجود چند حرف در چندین کلمه (k یا f در کلمات وجود داشته باشد) در c#.net :
using System;
using System.Text.RegularExpressions;
class MainClass {
private static void DisplayMatches(string text,string regularExpressionString) {
Console.WriteLine("using the following regular expression: " +regularExpressionString);
MatchCollection myMatchCollection = Regex.Matches(text, regularExpressionString);
foreach (Match myMatch in myMatchCollection) {
Console.WriteLine(myMatch);
using System.Text.RegularExpressions;
class MainClass {
private static void DisplayMatches(string text,string regularExpressionString) {
Console.WriteLine("using the following regular expression: " +regularExpressionString);
MatchCollection myMatchCollection = Regex.Matches(text, regularExpressionString);
foreach (Match myMatch in myMatchCollection) {
Console.WriteLine(myMatch);