Friday, 13 September 2013

Regex. Camel case to underscore. Ignore first occurrence

Regex. Camel case to underscore. Ignore first occurrence

For example:
thisIsMySample
should be:
this_Is_My_Sample
My code:
System.Text.RegularExpressions.Regex.Replace(input, "([A-Z])", "_$0",
System.Text.RegularExpressions.RegexOptions.Compiled);
It works fine, but if the input is changed to:
ThisIsMySample
the output will be:
_This_Is_My_Sample
How can first occurrence be ignored?

No comments:

Post a Comment