The strpos() function searches from the left side of the string. But instead of always trimming the string, I would like to get the position from the right side. Is there anyway to do this in the field calculator?

Here is the specific case of application:

enter image description here

I wanted to get the part of the string in "FolderPath" up the first '/' from the right.

  • 1
    I think this is a pure Python question about string manipulation that you would be better researching at Stack Overflow. – PolyGeo Jul 13 '16 at 8:56
  • Maybe,but I needed to solve it immediately and am not as firm to python as I wanted to be. Without creating a auxiliary field I used: right("FolderPath",length("FolderPath")-29). Since there are always 29 characters infront of my aimed string part. – Velester Jul 13 '16 at 9:01

I would use regexp_substr instead of strpos so in your example something like:


The first item ("FolderPath") is your column name (enclosed in "), the second is a standard python regular expression. There is a regexp howto available to help you out.

  • I'm playing around with your suggestion, but it doesnt work. ofc i used"regexp_substr()". Do you have a good documentation what to write in the 'regex'? – Velester Jul 13 '16 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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