Geographic Information Systems Asked by abrobia on August 23, 2020
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:
Does anyone know any way to modify/accommodate the expression?
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)
In the above example I used Path
instead of Location
Correct answer by ahmadhanb on August 23, 2020
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:
Answered by asongtoruin on August 23, 2020
substr("location",16,(length("location")-1))
or
substr(substr("location",17,14),1,6)
that will return "W48535"
Answered by user168488 on August 23, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP