Permalink
Browse files

Merge pull request #12568 from kevindugan/update-camelcase-conversion…

…-12567

Updating Regex to ignore underscores before uppercase characters
  • Loading branch information...
rwcarlsen committed Dec 4, 2018
2 parents 8da1c2d + 290978a commit ee396f660454d07e128f1529b795dbfa5251df9a
Showing with 4 additions and 1 deletion.
  1. +1 −1 framework/src/utils/MooseUtils.C
  2. +3 −0 unit/src/MooseUtilsTest.C
@@ -317,7 +317,7 @@ camelCaseToUnderscore(const std::string & camel_case_name)
{
string replaced = camel_case_name;
// Put underscores in front of each contiguous set of capital letters
pcrecpp::RE("(?!^)(?<![A-Z])([A-Z]+)").GlobalReplace("_\\1", &replaced);
pcrecpp::RE("(?!^)(?<![A-Z_])([A-Z]+)").GlobalReplace("_\\1", &replaced);
// Convert all capital letters to lower case
std::transform(replaced.begin(), replaced.end(), replaced.begin(), ::tolower);
@@ -23,6 +23,9 @@ TEST(MooseUtils, camelCaseToUnderscore)
EXPECT_EQ(MooseUtils::camelCaseToUnderscore("PhaseFieldApp"), "phase_field_app");
EXPECT_EQ(MooseUtils::camelCaseToUnderscore("XFEMApp"), "xfemapp");
EXPECT_EQ(MooseUtils::camelCaseToUnderscore("FOO_BAR"), "foo_bar");
EXPECT_EQ(MooseUtils::camelCaseToUnderscore("FoO__BAR"), "fo_o__bar");
}
TEST(MooseUtils, underscoreToCamelCase)

0 comments on commit ee396f6

Please sign in to comment.