Anonym 53 Posted September 23, 2012 Report Share Posted September 23, 2012 I have a huge list of files in the following format: <id>--<description>--<image_number>.jpg 102003--harddrive--1.jpg102003--harddrive--2.jpg102003--harddrive--3.jpg102003--harddrive--4.jpg102003--harddrive--5.jpg112079--monitor--1.jpg112079--monitor--2.jpg112079--monitor--3.jpg112079--monitor--4.jpg112079--monitor--5.jpg My intention is to find the files that corresponds to a certain ID and doing it, if possible with regex. I know it can be done by looping through the list and compare what is between start of string and "--", but I wonder of this can be found using regex? The question is whether it is possible to apply regexp on a list of strings, that is, neither a string, nor an attribute? Thanks! Quote Link to post Share on other sites
Aymen 385 Posted September 29, 2012 Report Share Posted September 29, 2012 i do not know exactly what are you trying to find , but here is the regex code for the file names format : [0-9]+\-\-[a-z]+\-\-[0-9]\.jpg if you want to look for a certain idyou can change it like this #idvar\-\-[a-z]+\-\-[0-9]\.jpg for example #idvar=112079then it will return 112079--monitor--1.jpg112079--monitor--2.jpg112079--monitor--3.jpg112079--monitor--4.jpg112079--monitor--5.jpg i hope this was helpful ! 1 Quote Link to post Share on other sites
LoWrIdErTJ - BotGuru 904 Posted September 29, 2012 Report Share Posted September 29, 2012 would be much easier using if contains then to use regex in my opinion.then you dont ahve to loop the list, or use find regex, and it might could come back empty and still ahve to process with an if statement anyway. parse once and done if $contains (%list, #whatyourlookingfor){than set found yeselse set found no Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.