fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var s = "- - - some text followed by more - - followed by more - - ";
  10. var res = Regex.Replace(s, @"^\W+", m => m.Value.Replace("-", "~"));
  11. Console.WriteLine(res);
  12. // => ~ ~ ~ some text followed by more - - followed by more - -
  13. Console.WriteLine(Regex.Replace(s, @"\G([^\w-]*)-", "$1~"));
  14. // => ~ ~ ~ some text followed by more - - followed by more - -
  15. Console.WriteLine(Regex.Replace(s, @"(?<=^\W*)-", "~"));
  16. // => ~ ~ ~ some text followed by more - - followed by more - -
  17. }
  18. }
Success #stdin #stdout 0.03s 134720KB
stdin
Standard input is empty
stdout
~ ~ ~ some text followed by more - - followed by more - - 
~ ~ ~ some text followed by more - - followed by more - - 
~ ~ ~ some text followed by more - - followed by more - -