How to find all words starts with @@ and ends with @@ in a string with C#

1 Answer

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

class Program
{
    static void Main() {
        string str = "ms@@ @@csharp@@ @@desktop @@software@@ @@development@@";

        MatchCollection mc = Regex.Matches(str, @"@@\b\S+?\b@@");

        foreach(Match m in mc) {
            Console.WriteLine(m);
        }
    }
}




/*
run:

@@csharp@@
@@software@@
@@development@@

*/

 



answered Oct 27, 2022 by avibootz

Related questions

...