I have a 'name' field with composite name; numbers and words e.g. "1237, Café"

I managed extract the part number with Field Calculator and make a new field (see 1) with this expression

left( "Name" , strpos( "Name" ,'\s') - 1)

But I can´t find the way to extract the part names - just words!

If I use this

regexp_replace( "Name" , '\W', ' ')

Creating a new field result only fields with numbers...(see 2)

EDITED: correction; the results with only numbers; if the type is "whole number (integer)"!!

Updating the 'name' field, result the same fields only without ','... e.g. "1234 Café"

enter image description here

  • 2
    To get the words only, you could try something like: regexp_replace( "name",'[\\d,]','')
    – cm1
    Commented Jan 17, 2018 at 20:55

1 Answer 1



Example: "1237, Café"

  1. To extract the number to a new field 'addr_num'

In the Field Calculator

  • New Field: 'addr_num'
  • Type: Whole number (integer)
  • Lenght: 10


left( "Name" , strpos( "Name" ,'\s') - 1)

[see post]

Result "1237"

  1. To extract the 'name' part to a new field 'new_name'

In the Field Calculator

  • New Field: 'new_name'
  • Type: Text (string)
  • Lenght: 80


regexp_replace( "name",'[\d,]','')

Result: " Café"

Credit: @cm1

But to trim spaces:

trim( regexp_replace ( "name",'[\d,]','') )




\s - whitespace

\d - digit

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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