Extracting part of string from field in QGIS Field Calculator?

Since the number of characters is same, you can use substr() function on a new field as in the following expression:

substr( "Location" ,17,6)

enter image description here

In the above example I used Path instead of Location


A couple of issues - first, you don't need to escape (i.e. put a backslash before) the underscore. Your pattern also suggests that the digits follow immediately after a forward slash - which they do not, there is a w between them in each of your examples. If this is consistently a w, you could do:

regexp_substr( "location", '/w(\\d*)_' )

but in reality, if you're just trying to get every number before the underscore, you'd be sufficient with:

regexp_substr( "location", '(\\d*)_' )

As can be seen here:

enter image description here