I need to replace upper case letter in variable name with lower case letter and add space
For example:
NotImplementedException
should be Not implemented exception
UnhandledException
should be Unhandled exception
Using character sets For example, the regular expression "[ A-Za-z] " specifies to match any single uppercase or lowercase letter. In the character set, a hyphen indicates a range of characters, for example [A-Z] will match any one capital letter.
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
matches any character. \U converts to uppercase.
RegEx makes replace ing strings in JavaScript more effective, powerful, and fun. You're not only restricted to exact characters but patterns and multiple replacements at once.
Since you did not specify a language, I'll give an example in C#. I am sure your language will offer something like it.
String s = "NotImplementedException"; s = Regex.Replace(s, @"\B[A-Z]", m => " " + m.ToString().ToLower()); // s = "Not implemented exception"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With