Is there any way to rename attribute from Proper Case to Underscore with BulkAttributeRenamer?
Here is a few examples
OrgNameComment -> Org_Name_Comment
TaxRegNumber -> Tax_Reg_Number
Ideas?
Thanks
Yarko
Is there any way to rename attribute from Proper Case to Underscore with BulkAttributeRenamer?
Here is a few examples
OrgNameComment -> Org_Name_Comment
TaxRegNumber -> Tax_Reg_Number
Ideas?
Thanks
Yarko
I would have thought it would a simple regex replace in the bulkAttributeRenamer, but it doesn't seem to allow you to use regex in the replacement string.
Incidentally you may have better luck searching using the terms CamelCase and Snake_Case.
You can access the matched string using \1 in the BulkAttributeRenamer, so if you match all words starting with a capital except the first one and then replace these with an underscore and themselves you should get what you are after
(?<!^)(yA-Z]+ra-z]+)
If there are any numbers or other characters in your attribute names the regex will need amending
You can access the matched string using \1 in the BulkAttributeRenamer, so if you match all words starting with a capital except the first one and then replace these with an underscore and themselves you should get what you are after
(?<!^)(yA-Z]+ra-z]+)
If there are any numbers or other characters in your attribute names the regex will need amending
Argh, the replace slash is quirky, I was getting unhappy results with my original regex.
Yarko,
There are several variations in regex that will give you great results if all your attributes are straight camel case, but if you have any attributes that aren't, the behaviours change.
See for example \B(A-Z]) vs Elizabeth's regex (?<!^)(eA-Z]+A-z]+)
You can access the matched string using \1 in the BulkAttributeRenamer, so if you match all words starting with a capital except the first one and then replace these with an underscore and themselves you should get what you are after
(?<!^)(yA-Z]+ra-z]+)
If there are any numbers or other characters in your attribute names the regex will need amending
This works beautifully ,
Thanks @ebygomm
Argh, the replace slash is quirky, I was getting unhappy results with my original regex.
Yarko,
There are several variations in regex that will give you great results if all your attributes are straight camel case, but if you have any attributes that aren't, the behaviours change.
See for example \\B(\A-Z]) vs Elizabeth's regex (?<!^)(^A-Z]+ZA-z]+)
"Argh, the replace slash is quirky, I was getting unhappy results with my original regex."
I normally spend at least 5 minutes working out why \\1 isn't working in the string replacer before remembering i need brackets to get capturing groups