Jump to content
Ketarin forum

need Second or more result to regex


Guest dams
 Share

Recommended Posts

 
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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

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