How to find substrings with single quotes in a string with C#

1 Answer

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

namespace ConsoleApplication_C_Sharp
{
    static class Program
    {
        static void Main()
        {

            string s = "java 'c#' python 'php' c++";

            MatchCollection matchcollection = Regex.Matches(s, "'(.*?)'");

            foreach (Match mc in matchcollection) {
                    Group g = mc.Groups[1];
                    Console.WriteLine(g.Value);
            }
        }
    }
}


/*
run:
  
c#
php
   
*/

 



answered Oct 10, 2018 by avibootz

Related questions

1 answer 240 views
1 answer 121 views
1 answer 92 views
2 answers 141 views
1 answer 115 views
...