How to match the $ special character using regular expression in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main()
    {
        Regex pattern = new Regex("\\$");
        string s = "It's only $10.00 today";

        bool match = pattern.IsMatch(s);

        Console.WriteLine(match);
    }
}



/*
run:

True

*/

 



answered Feb 16, 2025 by avibootz
...