Home > Enterprise >  QString convert camel case to space separated words
QString convert camel case to space separated words

Time:06-03

I am trying to convert a camel cased QString into lowercased words separated by spaces. I currently have:

QString camelCase = "thisIsACamelCaseWord"
QString unCamelCase = camelCase.replace(QRegularExpression("([A-Z])", " $1")).toLower();

Which seems to work here,

"this Is A Camel Case Word"

but it is returning with:

"this $1s $1 $1amel $1ase $1ord"

CodePudding user response:

Since QRegularExpression uses PRCE the back reference syntax is '\0', '\1' and so on as explained in the documentation.

  • Related