How to extract first names from people in a list?

Hello, I am having trouble figuring this out. I have a group, group.anyone, that has a list of everyone that could possibly be at home. I have automations that send notifications to me for different reasons, i.e. camera alerts. In those notifications I have it telling me who is home. I’m wondering if there is a way to extract just the first name of the person before the space in the name? Here’s my code as it exists now:

{{expand('group.anyone')|selectattr('state', 'eq','home')|map(attribute='name')|list|join(', ') }}

This is nice because it will give me ‘Bob Smith’ if only one person is home, or ‘Bob Smith, Adam Smith, Joe Smith’ if more than one person is home. I would like it to only say ‘Bob’ or ‘Bob, Adam, Joe’. Does anyone know how I might accomplish this?

Pop this between the list and the join:

|map('regex_replace','\ .*','')

Brilliant!!! Thank you so much, that works perfectly!