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?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
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).