Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,
I am trying to make Regex pattern.
so, the user input string with letters. ("bcade")
what is the Regex pattern, to make this input look like -> abcde?
Thanks for answers :)
Posted

1 solution

There is no sensible regex which will do that - it is a job for a sort routine.
The easiest way is to convert the string to a character array, sort it, and convert back to a string again.

C#
string s = "bcade";
char[] chars = s.ToCharArray();
Array.Sort(chars);
s = new String(chars);
Console.WriteLine(s);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900