3

What are the right functions and formulas with the field calculator to delete "alphabet" or "number" inside a field?

Let me be clear. I want to be able to delete "alphabetic letters" or "numbers" inside my records (see the image). I've used replace, left, substr functions, but they don't make any difference between "alphabet" and "number".

enter image description here

3
  • 3
    Please edit your question to show us a sample on how the texts in the attribute table are look like.
    – ahmadhanb
    Sep 2 '20 at 23:27
  • when extracting apply: for integers use to_int(regexp_substr("field_name", '(\\d+)')) and for symbols to_string(regexp_substr("field_name", '[A-Za-z]+')). when deleting use regexp_replace()instead.
    – Taras
    Sep 4 '20 at 11:46
  • @Taras, your formulas are working!!! Tank you very much for your help.
    – Yems
    Sep 5 '20 at 16:01
1

To split your field into subfiels, i.e. "alphabetic" or "numeric" apply:

for integers:

to_int(regexp_substr("field_name", '(\\d+)'))

that will give you '199' from '199 (ME)'

for symbols:

to_string(regexp_substr("field_name", '[A-Za-z]+'))

that will give you 'ME' from '199 (ME)'


References:

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.