I have the following in a helper extension:
return Regex.Replace(str,
"(?<=[a-z])(?<x>[A-Z])|(?<=.)(?<x>[A-Z])(?=[a-z])|(?<=[^0-9])(?<x>[0-9])(?=.)",
" $1");
Which will effectively take
WhateverIPutInToIt
and render
Whatever I Put In To It
except that I would prefer not to capitalize each proper word. However, if I do not capitalize then it will not render with the spaces.
I thought I would instead try to take something like
Whatever_I_put_into_it
to render what I want. I cannot figure out how to do a regular expression (if its even possible) to strip out the the "underscore" character and replace it with a space.
Any help?
Update:
Sorry for not being clear. This is in a helper extension to convert enums I have into something readable. I am using the helper for my dropdownlists and checkboxlists. I have over 10 enums for those, and to do each one individually would be a pain. Was hoping that I could just fix the Regex.Replace
code at the top to something that would accomplish what I am after.
Mind you, if I do
YouHave9OrMore
the above Regex.Replace
will spit out (it splits out the number "9")
You Have 9 Or More
Thank you all for the quick comments.