win_lineinfile | Regex

Hi,
I need to update a property in a file but the value i need to write depend of the inventory_hostname.
If the hostname is ABCAPP1.MYDOMAIN.COM the value i need to write is APP1
If the hostname is ABCDB1.MYDOMAIN.COM the value i nedd to write is DB1

How can i do this?
Thanks,
TP