underScoreToTitle function

String underScoreToTitle(
  1. String s
)

Helper function to convert an underscore string s to Title case.

Example:

hello_world -> Hello World

Implementation

String underScoreToTitle(String s) {
  s = s.replaceAllMapped('/(\_[a-z])/g',
      (Match $1) => $1.toString().toUpperCase().replaceAll('_', ' '));
  s = s.replaceAll(s[0], s[0].toString().toUpperCase());
  return s;
}