Example Camel Cased
- ThisIsOneExample
- TomorrowIsWhatDay
- ThisIsAnotherExample
ASPX Page
<asp:Label ID="Label1" runat="server" Text="Camel Words"></asp:Label>: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Convert" onclick="Button1_Click" /> <br /> Preview : <asp:Literal ID="Literal1" runat="server"></asp:Literal> <br /> <p> </p> <p> </p>
Code Behind
protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string camelWords = TextBox1.Text; IEnumerable<string> _words = SplitCamelCase(camelWords); foreach (string a in _words) { Literal1.Text += a + " "; } } /// <summary> /// Splits the camel cased input text into separate words. /// </summary> /// <param name="text">Camel cased text</param> public IEnumerable<string> SplitCamelCase(string text) { var matches = Regex.Matches(text, "[A-Z]+(?=[A-Z][a-z]|[0-9]|$)|[A-Z][a-z]+|[0-9]+"); return matches.Cast<Match>().Select(m => m.Value); }
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
0 comments:
Post a Comment