Scan and rename selected finder item

I've asked similar questions on this, but I hope this makes more sense.

I have a finder window open and active. I then click one of the items so it becomes highlighted. (This might be the 3rd file down in the folder.

Then when I scan with barcode reader it then renames that file.

The problem; as the scanner input start with a 5, finder want to then go to the file that begins with 5 as there are none the selected file is now at the top and then the wrong file is renamed.
How can ignore that initial input but remember for use later in the macro?

I've since tested changing the "typed string" to a hotkey i've select numkey 5 and the behaviour is as expected. The problem I presume is in the string?

Barcode Scanner Trigger example.kmmacros (21.5 KB)

Instead of this RegEx:

You might try this, which will eat any/all characters prior to the "503":


I've given that a go and I get the same result.
Is it due to the following numbers that makes it jump to the top?
Can I make it eat all the keystrokes? The barcode is 13 Characters (14 including the return stroke that comes from scanning) Not sure if you can specify the number of characters to delete