fork(29) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Example
  5. {
  6. public static void Main()
  7. {
  8. string input = "CamelCase";
  9. string output = Regex.Replace(input,
  10. @"(?:\b|(?<=([A-Za-z])))([A-Z][a-z]*)",
  11. m => string.Format(@"{0}{1}",
  12. (m.Groups[1].Value.Length > 0)? "_" : "", m.Groups[2].Value.ToUpper()));
  13. Console.WriteLine(output);
  14. }
  15. }
Success #stdin #stdout 0.07s 37280KB
stdin
Standard input is empty
stdout
CAMEL_CASE