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

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

Let's say I have this code
"https://files3.lynda.com/secure/courses/193222/exercises/fichiers_source.zip?IfhMRRu4plADtilpite7a0zPEghAhgvCQTJQ5SOAtBX-OKKqYPaGpQHCXCVRnnmfucTqgq-4w5LbQ1q4RgfJ6tdZUQv-IwhMqHl3usOg9xFhGijrble1n60q11gUa4__nBWc_h466E8OD9S1USFx7jr2","$type":"com.linkedin.learning.api.ExerciseFile","$id":"DetailedCourse;urn:li:lyndaCourse:193222,-1674916998"},{"progressiveUrl":"https://files3.lynda.com/secure/courses/193222/VBR_MP4h264_main_SD/FR_421_trailer_WL25.mp4?AcbHhYy2CIHoQk-JWlfXPBYju6lA_MWnkeax1WpB1WXkPBgLnuDRAZ8V8GfYP2MwhAhAJw2vvr64MXWe1lFL9nEz7Ykxb06NZNvXvZ-FIlZct94PUwiAfXIQy4Nrti7jeq0cWfQaBMPl_DJJrF9NU3sLbG1Tc1ii6agkShiZf7M","streamingUrl":"https://s2.lynda.com/secure/courses/193222/streaming/FR_421_trailer_WL25_,480,340,724,200,110,1200,1650,.mp4.m3u8?D4WVSRpMLwN2luRp3mS2nG_xU5yP9VYF0UCmYlzgI8RvMB-PVvcsbDZI2RWzy-wvWdCMaKUq5rauWOgBct41YqPAbRzzFTbwaiZddnGLL8fzAHNq_SKVdvY8dczNMQTHpLBghoEDhN7mx09rOyvHFVUn","expi

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

FR_421_trailer_WL25.mp4

or even better

421

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

FR_.*mp4

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:

FR_.*?\.mp4

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)

###Results

1 Like

Than you so much. It works as expected now.

1 Like