Search this blog

Wednesday, 30 March 2011

Renaming attributes with regular expressions

If you have an attribute with this name


and you want to rename it to


Use the 'Rename By Replacing' operator with this


in the 'replace what' field



in the 'replace by' field.

The brackets denote what is known as a capturing group so that everything inside that matches can be used later on by the use of the $1, $2 and $3 entries. The '.*' means match 0 or more characters and will continue until the '_' is found. The capturing group brackets mean that everything from the beginning of the string up to the character before the '_' will be placed into capturing group 1.

No comments:

Post a Comment