What I’m trying to do seems like something that should be relatively simple.
I have a block of text that’s part of a message, and in it are the file paths of files that need to be attached to an outgoing email.
For example, a line in the message could be (brackets are part of the message text as well):
(File Attachment: /home/username/public_html/someFile.pdf)
There could be multiple files per message, but each would be listed on a separate line and each would begin with “File Attachment: “ and be enclosed in brackets.
I’m trying to figure out how to use regular expressions to:
- check if the message contains the string “(File Attachment: .......)“
- for each attachment, get the file name that’s listed as a PHP variable.
- Remove the entire “File Attachment: “ line from the original message.
I know how to do everything else, it’s just this part I’m stuck on and could use a little help with because I don’t understand regular expressions at all.
A sample message would be something like this:
Application #123456 has been APPROVED!
(File Attachment: /home/username/public_html/someFile.pdf)
(File Attachment: /home/username/public_html/someFile2.pdf)
What I’d like is to get a PHP array with “ /home/username/public_html/someFile.pdf” and “ /home/username/public_html/someFile2.pdf”, and for those sub strings to be completely removed from the message.