21 //Yerine gelebilecek herhangi bir karakteri temsil eder. Aşağıdaki desen bize :
22 //muty, mu5y, muzy gibi sonuçlar döndürebilir.
23 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("mu.y", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
24 MatchCollection match1 = regex.Matches(textBox1.Text);
25
26 if (match1.Count > 0)
27 {
28 foreach (Match var in match1)
29 {
30 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
31 }
32 }
2. "[]" Karakteri
1 //Dizi tanımlayabilmemize veya aralık belirtebilmemizi sağlar. Aşağıdaki desen bize :
2 //muay, muby, mucy, mudy ve muey sonuçlarını döndürken, aralık dışında olan muhy sonucunu döndürmeyecektir
3 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("mu[a-e]y", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
4 MatchCollection match1 = regex.Matches(textBox1.Text);
5
6 if (match1.Count > 0)
7 {
8 foreach (Match var in match1)
9 {
10 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
11 }
12 }
3. "?" Karakteri
1 //Kendisinden önce gelen karakterin karşılaştırma yapılan metinde olmasını veya olmamasını sağlar.
2 //Aşağıdaki desenden mumy veya muy sonuçları dönebilir.
3 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("mum?y", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
4 MatchCollection match1 = regex.Matches(textBox1.Text);
5
6 if (match1.Count > 0)
7 {
8 foreach (Match var in match1)
9 {
10 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
11 }
12 }
4. "\" Karakteri
1 //Özel karakterleri string içerisine dahil edebilmemizi sağlar.
2 //Örneğin desende System.Text.RegularExpressions.Regex("ok\?") yerine System.Text.RegularExpressions.Regex("ok?") verseydik sonuç olarak bize "o" veya "ok" dönerdi.
3 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("ok\\?", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
4 MatchCollection match1 = regex.Matches(textBox1.Text);
5
6 if (match1.Count > 0)
7 {
8 foreach (Match var in match1)
9 {
10 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
11 }
12 }
5. "*" Karakteri
1 //Kendisinden önce gelen karakterin veya karakter bloğunun hiç olmamasını veya birden fazla sayıda olmasını sağlar.
2 //Örneğin System.Text.RegularExpressions.Regex("Muammer*") deseni; Muamme, Muammer, Muammerr gibi sonuçlar döndürür. System.Text.RegularExpressions.Regex("Muam(mer)*") deseni ise Muam, Muammer, Muammermer gibi sonuçlar döndürür.
3 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("Muam(mer)*", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
4 MatchCollection match1 = regex.Matches(textBox1.Text);
5
6 if (match1.Count > 0)
7 {
8 foreach (Match var in match1)
9 {
10 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
11 }
12 }
6. "{}" Karakteri
1 //Kendisinden önce gelen karakterin belirtilen sayı kadar tekrar ederek gelmesini sağlar.
2 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("Muam{2}er*", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
3 MatchCollection match1 = regex.Matches(textBox1.Text);
4
5 if (match1.Count > 0)
6 {
7 foreach (Match var in match1)
8 {
9 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
10 }
11 }
7. " ^ " Karakteri
1 //Verilen değerin satır başını işaret eder. Aşağıdaki desen, eğer verilen cümle veya text bloğunun en başında Muammer kelimesi varsa olumlu sonuç döndürür.
2 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^Muammer", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
3 MatchCollection match1 = regex.Matches(textBox1.Text);
4
5 if (match1.Count > 0)
6 {
7 foreach (Match var in match1)
8 {
9 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
10 }
11 }
8. "$" Karakteri
1 //Verilen değerin satır sonunu işaret eder. Aşağıdaki desen, eğer verilen cümle veya text bloğunun en sonunda Muammer kelimesi varsa olumlu sonuç döndürür.
2 System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("Muammer$", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
3 MatchCollection match1 = regex.Matches(textBox1.Text);
4
5 if (match1.Count > 0)
6 {
7 foreach (Match var in match1)
8 {
9 textBox1.Text = textBox1.Text.Replace(var.Value, "yeni değer");
10 }
11 }
Bunların dışında birtakım özel karakterlerde mevcuttur.