c# - Add spacing between lowercase and uppercase? -
i add together space when uppercase character or underscore in string.
how do this?
example 1
input
thisisaninputstring output (result)
this input string example 2
input
this_is_an_input_string output (result)
this input string
you can utilize regular look matches lower case character followed upper case character, optional underscore between:
string output = regex.replace(input, "([a-z])_?([a-z])", "$1 $2"); you might want utilize handle single character words also:
string output = regex.replace(input, "(?<!^)_?([a-z])", " $1"); c# string
No comments:
Post a Comment