Can't make a regex work - with search in file action

I am very sorry to ask your attention for such a simple thing.

Let's say I have this code

contained in a html page stored locally at
/Volumes/SSD 525 1/OneDrive/LinkedIn Learning Video2Brain Lynda/%Variable%titreducours%.html

I can check that the file is found by KM with reveal file action, works fine.

My goal is to find this in the code


or even better


Good to know :

  • there can be more than 3 digit
  • the string always begins with FR_
  • and always ends with .mp4

I use search in file action with the following regular expression


This works but it doesn't stop at the first occurence. It finds this

Thanks for your help.

The way to get the regex to stop at the first occurrence is to make it non-greedy with a question mark:


However, if your real goal is just to extract these strings of 3+ digits, one of the simpler ways may be to actually employ two sets of regexes and For Each actions:

Search for NumCodes in File.kmmacros (5.1 KB)


1 Like

Than you so much. It works as expected now.

1 Like