简体   繁体   中英

QString convert camel case to space separated words

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"

由于QRegularExpression 使用PRCE ,因此后向引用语法为'\0'、'\1'等,如文档中所述。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM