So I have a regex that breaks a string apart that assumes camelCase or PascalCase and converts it into lowercase_with_underscores. That regex looks like this (php):
strtolower(preg_replace('/(?!^)[[:upper:]]/','_\0', $string));
I want to modify this so that it will be able to also break up the string where it assume a string of capitalizes in a row as one unit. For example, I would to be able to break up the following strings:
'GUID' => 'guid'
'SOME_VALUES' => 'some_value'
'someThingELSE' => 'some_thing_else'
Any suggestions on how to modify the regex to do this?
How about: