May-01-2023, 04:20 AM
(This post was last modified: May-01-2023, 03:24 PM by deanhystad.)
It probably gave you trouble because of the non-greedy matching. Another possibility is you might have used a control sequence where you wanted a backslash.
Why not grab all the digits instead of looking for the character after the digits?
Why not grab all the digits instead of looking for the character after the digits?
import re pattern = re.compile(r'DJI_(\d+)') matches = re.findall(pattern, 'DJI_0991.MP4 DJI_0992 - testing.MP4 JI_0993 - testing.MP4 DJI 0994.MP4') print(matches)
Output:['0991', '0992']