I have the following string:
"<a href=\"/formentries/formfile/13978\" target=\"_blank\">dog-00.jpg|image/jpeg</a> <a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13978'> [remove]</a><br /><a href=\"/formentries/formfile/13979\" target=\"_blank\">dog-01.docx|application/vnd.openxmlformats-officedocument.wordprocessingml.document</a> <a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13979'> [remove]</a><br /><a href=\"/formentries/formfile/13980\" target=\"_blank\">dog-02.png|image/png</a> <a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13980'> [remove]</a>"
If you were to format that nicely, you'll see something like this:
<a href=\"/formentries/formfile/13978\" target=\"_blank\">dog-00.jpg|image/jpeg</a>
<a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13978'> [remove]</a>
<br />
<a href=\"/formentries/formfile/13979\" target=\"_blank\">dog-01.docx|application/vnd.openxmlformats-officedocument.wordprocessingml.document</a>
<a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13979'> [remove]</a>
<br />
<a href=\"/formentries/formfile/13980\" target=\"_blank\">dog-02.png|image/png</a>
<a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13980'> [remove]</a>
So I have a bunch of anchor tags with breaks between them. In each anchor's text, I want to remove the pipe character and the file type:
dog-00.jpg|image/jpeg
becomes
dog-00.jpg
And the regex ought to work for all future file types too, for example:
dog-01.docx|application/vnd.openxmlformats-officedocument.wordprocessingml.document
becomes
dog-01.docx
I still need the full anchors, so after removing the file type, the text becomes:
<a href=\"/formentries/formfile/13978\" target=\"_blank\">dog-00.jpg</a>
<a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13978'> [remove]</a>
<br />
<a href=\"/formentries/formfile/13979\" target=\"_blank\">dog-01.docx</a>
<a href='/FormEntries/Delete' class='btnDeleteAttachment' data-form-entry-id='366793' data-attachment-id='13979'> [remove]</a>
<br />
I am not very good at Regex, but I tried various combinations that all failed to match