You could do something like this. Admittedly, the expression can probably be cleaned up.
with_variable('options', array('buildings', 'facilities', 'real estate'), -- pre-determined list of layer names
with_variable('layer_names', array_foreach(@layers, layer_property(@element, 'name')),
@element > 0
-- the original expression
layer:=@existing_layer_name, -- the result of the matching procedure above
It basically matches the layer names in the project against a pre-determined list. If more than one match is found then it uses the first one.
array_find returns the index of the found element, and
array_get uses that index to pull the layer name from the array of 'options'.
array_filter is used to remove any
-1 returned by
The following two screenshots omit the original expression to demonstrate what is returned by the match.