Jump to content
UBot Underground

Finding files in a list using regexp - is it possible?


Recommended Posts

I have a huge list of files in the following format:

 

<id>--<description>--<image_number>.jpg

 

102003--harddrive--1.jpg

102003--harddrive--2.jpg

102003--harddrive--3.jpg

102003--harddrive--4.jpg

102003--harddrive--5.jpg

112079--monitor--1.jpg

112079--monitor--2.jpg

112079--monitor--3.jpg

112079--monitor--4.jpg

112079--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!

Link to post
Share on other sites

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 id

you can change it like this

 

#idvar\-\-[a-z]+\-\-[0-9]\.jpg

 

for example #idvar=112079

then it will return

 

112079--monitor--1.jpg

112079--monitor--2.jpg

112079--monitor--3.jpg

112079--monitor--4.jpg

112079--monitor--5.jpg

 

i hope this was helpful !

  • Like 1
Link to post
Share on other sites

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 yes

else set found no

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...