As anyone who’s seen my posts will know, I’m a regex pleb. Anyone can tell me how to get the ID from this file name, would be very grateful?
/data/64786/sasf.zip
I need the 64786 bit from this line, always follows /data/ – anyone able to help quickly?
This will match a sequence of decimals (0-9) immediately following the string
/data/. Match is in group1.If the string can also look like
/data/64786(i.e., nothing after the number), use~/data/(\d+)~instead. Actually, you can use this either way since\d+will be greedy per default and thus match as many decimals as possible. (Tested at Rubular.)