I am trying to extract HostName and Email address from text file using regex. These fields are optional. It is possible that in some cases only one field is available.
For example: if email address is not available is should extract only hostname and vice versa.
I got nearly working regex. Just not working for single case. see the regex in below link.
regex: ^.*(MAIL:(?<EMAIL>.*))(HOST:(?<HOSTNAME>.*))?
https://regex101.com/r/SDOcIR/1
Note: I am not looking this for specific language.
Thanks
MAIL:(?<EMAIL>.*)|HOST:(?<HOSTNAME>.*)(demo)?