fork(5) download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var s = "All men like widgets but some men like widgets more than others";
  10. var chunks = Regex.Split(s, @"(\s*\bwidgets\b\s*)");
  11. string result = string.Concat(chunks.Select((i, index) => index % 2 == 0 ? $"<b>{i}</b>" : i));
  12. Console.WriteLine(result);
  13. }
  14.  
  15.  
  16. }
  17.  
  18.  
Success #stdin #stdout 0.04s 134592KB
stdin
Standard input is empty
stdout
<b>All men like</b> widgets <b>but some men like</b> widgets <b>more than others</b>