Jump to content
Ketarin forum

need Second or more result to regex


Recommended Posts

Guest dams
 
Hello ,


I would like to know how to select the second or third ... result of a regex with ketarin

Ketarin only selects the first valid result of a regex!

I would like him to select the second or third ...


the goal is to download several links on the same web page with a never identical and unknown link name
Link to post
Share on other sites

This is by design. RegEx is an explicit language and the syntax is intended to be consistent. If you want to select the second or third instance just include the regex twice (for the second instance) or three times (for the third instance), and so on, with ".+?" connectors. Here's an example for selecting the newest and two other recent versions of FFmpeg from here.

First instance:

(/[^'"<>]+win64-gpl.zip)

Second instance:

/[^'"<>]+win64-gpl.zip.+?(/[^'"<>]+win64-gpl.zip)

Third instance:

/[^'"<>]+win64-gpl.zip.+?/[^'"<>]+win64-gpl.zip.+?(/[^'"<>]+win64-gpl.zip)

 

Link to post
Share on other sites

When including screenshots it's best to also include the specific regex patterns or other data as text so it's easier to read.

Your problem is in the second parentheses group. It should either have the parentheses removed or have "?:" included to make it a non-capturing group. Note in my example that I only attempted to capture the final group. If you capture previous text regex will stop processing there.

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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.