0

I am trying to create a new attribute field in a layer that converts a string with characters into an integer.

EXAMPLE: 234' -> 234 or 234'* -> 234

Any ideas on how to accomplish this?

1
  • 1
    All values start with number? And all characters always come after the numbers? What if the value is **234'*2345-+? @MrXsquared meant this kind of details. – Kadir Şahbaz Feb 20 at 18:50
1

If you are sure the numbers you want from the string are positive and integers only, then you can use an expression in the Field Calculator like regexp_substr( "Fieldname" , '(\\d*)' ). Or, if there are possibly negatives and/or real numbers try this: round(regexp_substr( "Fieldname" , '([.-0123456789]+)' ),0).

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.