2

I am trying to PREPEND some dynamic data with postfix header_checks. Namely, my mailing software doesnt support List-unsubscribe feature, so I am trying to overcome that with prepending it with postfix header_checks

My regex is currently like this

/^To:(.*)$/   PREPEND List-Unsubscribe: https://www.example.com/unsubscribe.php?list=1&email=$1

However, when it gets rewritten, or rather added to email header that link becomes

https://www.example.com/unsubscribe.php?list=1&email= random@email.com

So, my question is basically how to remove that leading whitespace from regex above?

thanks in advance

Kosta
  • 189
  • 1
  • 1
  • 9

1 Answers1

4

You may actually consume the whitespace(s) with \s* (=zero or more whitespaces):

/^To:\s*(.*)$/
     ^^^ 

See the regex demo.

If the email is just a chunk of non-whitespace characters after 0+ whitespaces, you may even use

/^To:\s*(\S+)/

where \S+ matches one or more characters other than whitespace.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563