I need to filter filenames (like DJI_0147_3_5.jpg) in an array, and the code below works, but, where you see a 3 in regex, I need instead a field value.
In the array output (sourcefile field) we have a list of filenames paths and I want to get (filter by "filename" field) only those wich contains the field value inside (not exact match) in the final part (after the second underscore). The field value is "Fab_num", wich is a simple buildng number (ex. 3).
If I put a field instead of 3 it doesn't work.
If I use array_contains, it uses only exact match.
array_get( string_to_array( aggregate ('Vettore_unito_a9e2e647_ceed_4b78_8400_1b5e06c8b159', 'concatenate_unique' , "sourcefile", filter:=intersects( $geometry, geometry(@parent))AND regexp_match ( "filename", '(_.+_).*3' ), concatenator:=',' ) ) ,0)
the final 0 is to get the first element in the array. The array is from layer 'Vettore_unito....' wich is a building layer one-to-many (reapeted the same building for every photo related to it).
array_get( [your_array], 0)
, you can use[your_array][0]
- adding a number (index) in square brackets at the end of an array returns the n-th element of the array.