Search code examples
regexperlemailspam-prevention

How can a Content-Disposition filename be matched using a regex?


How can a Content-Disposition filename be matched using a regex ? I need to enter a regex in an antispam software which should match the following

Content-Disposition: attachment;
 "filename"=attached.bat

where attached could be any filename word.

Also this should not be matched

Content-Disposition: attachment;
other text here
 "filename"=attached.bat

I would match (and block) using a regex all email having the text above. Is it possible using a single regex row ?

note : I found a way to match "Content-Disposition: attachment;" OR "filename"=attached.bat" using 2 separate regex, but I would match "Content-Disposition: attachment;" AND "filename"=attached.bat" using a single regex. Is it possible ?

Thank you


Solution

  • Try Content-Disposition: attachment;\s*"filename"=[-+.\w]+.

    http://www.regexr.com/3d4p4