I need a generic way to convert classnames to lowercase with underscores. For example, I wish to convert the classname NewUserBatch to new_user_batch. How to do this?
I need a generic way to convert classnames to lowercase with underscores. For example,
Share
In the simple case, where you only have non-namespaced class names, you can use this oneliner:
EDIT: updated with positive look-ahead assertion (thanks @vladr)
This finds all uppercase chars that follow another char and in turn is followed by a lower case char, inserts underscore before it and then downcases everything.