fork(3) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Text.RegularExpressions;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var str = "Please write a program that breaks this text into small chucks. Each chunk should have a maximum length of 25 ";
  10. var chunks = Regex.Matches(str, @"(\b.{1,25})(?:\s+|$)")
  11. .Cast<Match>().Select(p => p.Groups[1].Value)
  12. .ToList();
  13. Console.WriteLine(string.Join("\n", chunks));
  14. }
  15. }
Success #stdin #stdout 0.11s 24760KB
stdin
Standard input is empty
stdout
Please write a program
that breaks this text
into small chucks. Each
chunk should have a
maximum length of 25