I have a table with two fields A and B, and i want fill field B with "some values" from field A:

FieldA: 123456_CC; 123_D; 1234567_AB; 123456768_F

I just need the "text" that is associated with the value of the field

FieldB: CC; D; AB; F

What expression to create this?


Assuming all of your row values are in the form chunkA_chunkB, you can use the following expression in the field calculator:


This method actually breaks the string into a list of selectable items. To illustrate, in the python interpreter:

>>> row1 = '123456_CC'
>>> row1.split("_")
['123456', 'CC']

And to select just the second item in the list:

>>> row1.split("_")[1]

Not the answer you're looking for? Browse other questions tagged or ask your own question.