Bug in save attachments activities even if already using regex filter

IF activity:
attach.Name.ToString.StartsWith(“QUOTATION”) And
(attach.Name.ToString.ToLower.EndsWith(".xlsx") Or attach.Name.ToString.ToLower.EndsWith(".xls"))

Regex Escape filter for Save Attachments activity:

Write line output of the regex escape:
QUOTATION-X31976-K645\ (test).xlsx
test\ QUOTATION-X31976-K645\ -\ Copy.xlsx
test\ QUOTATION-X31976-K645.xlsx

but why the saved attachments are these file:
QUOTATION-X31976-K645 (test).xlsx
test QUOTATION-X31976-K645.xlsx → i don’t want this file to be saved (look at my IF activity)

what is wrong?


If we need exact match in regex, ^ and $ need to be added as the following.



i’m about to tag u to help me lol.

ok i will try this.

1 Like

it didn’t save anything now :frowning: any other idea?


Thank you for trying.

I suppose the file path to be filtered is some full path (contains directory name etc). So can you try the following pattern?



yabai, it worked!


can u explain why


is worked, instead of


it’s just because the path to save file is full path??


Probably the attached files are stored somewhere in file system. And Save Attachment activity seems to filter the full path of attached file with regex pattern.

For example, if the attachment is “test.docx”, the file is strored as c:\somewhere\XXXXXX\test.docx and Save Attachment try to get files using the full path. So this is reason why there is no result if we use ^ meta character in regex.

It might be better the pattern will be "(^|\\)"+System.Text.RegularExpressions.Regex.Escape(attach.Name)+"$", because of prepare for improvement in the future.


based on your explanation,

i tried to delete my attachment from c:\somewhere\XXXXXX\file test.docx and also delete from recycle bin after i send the file to email as attachment to be saved by RPA.

then i tried to save the attachments using
but it also worked.

then i tried also your 3rd solution
it also worked.

Well, i’ll just use your 3rd solution just in case of improvement in the future.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.