QGIS Field Calculator – Extract Part of String from Field

attribute-tableexpressionfunctionqgisstring

I want to create a new field in my attribute table. My goal: returning all digits between the / and _ characters of the field named "location" by applying the next expression:

regexp_substr( "Text", '/(\\d*)\_' )

based on this working example: Obtaining specific part of string from field in QGIS attribute table?

However, the expression does not give the desired result in my case:

enter image description here

Does anyone know any way to modify/accommodate the expression?

Best Answer

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