1

One of the columns in my attribute table is called "table_ot". Some of the features in that column start with a letter. Example: table_ot = G 190 I want to delete all the letters at the start of the feature's value and end up with something like this: table_ot = 190

Can you please write down the correct code for the field calculator? I tried some things that don't run.

  • Are your numbers all of the same length, e.g. all of them three digits? Or are the letters all the same? Also, if you posted some of your trials, that could be helpful. – Erik Jul 18 '18 at 10:04
  • I tried something like this: replace ( "table_ot" , 'G ' , '' ) – Ntelo Jul 18 '18 at 10:39
1

if everything after the first letter is a digit, you can use

regexp_substr("table_ot",'(\\d+)')

  • Does this also work, if there is no beginning letter? – Erik Jul 18 '18 at 11:04
  • 1
    yes, this expression extract every digit in a value. If there is no letter in it, it just returns the number – PieterB Jul 18 '18 at 11:05
  • I copied the expression: regexp_substr("table_ot",'(\\d+)') It still doesn't let me run it. – Ntelo Jul 18 '18 at 12:18
  • 1
    can you describe which steps you tried, because I tried different values and it works – PieterB Jul 18 '18 at 12:28
  • I simply open the field calculator and paste the above expression in the left window. – Ntelo Jul 23 '18 at 5:35

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.