Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
HawkSearch field naming convention
//Microsoft (R) Visual C# Compiler version 3.4.0-beta4-19562-05 (ff930dec) //Copyright (C) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { Console.WriteLine(GetStandardFieldName("Hello, world!")); Console.WriteLine(GetStandardFieldName("99Hello, world!")); Console.WriteLine(GetStandardFieldName("_1Hello, world!_")); } public static string GetStandardFieldName(string InputField) { var rgx = new System.Text.RegularExpressions.Regex("[^a-zA-Z0-9_]"); string SField = InputField; SField = SField.Replace(" ", "_"); SField = rgx.Replace(SField, ""); if (!string.IsNullOrEmpty(SField)) { SField = SField.ToLower(); if (SField.StartsWith("_")) SField = SField.Remove(0, 1); if (SField.EndsWith("_")) SField = SField.Remove(SField.Length - 1); } if (!string.IsNullOrEmpty(SField)) { if(int.TryParse(SField.Substring(0, 1), out int result)) SField= "n" + SField; } return SField; } } }
run
|
edit
|
history
|
help
0
Some C# advanced stuff
HTML Hex to RGB without using System.Drawing C#
memes
C# URI parts url
newMultQ working on more2
salary
Coding Exercise
Conversioni double
Prueba
1