2

How can I download the versions from the link? I tried to do it with regEx but it didn't work as I wanted.

I wish it would work like this (Where I gave NULL, there is nothing to choose from)

https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js > 1.11.2
https://ajax.googleapis.com/ajax/libs/jquery/v1.11.2/jquery.min.js > 1.11.2
https://ajax.googleapis.com/ajax/libs/jquery/version-1.11.2/jquery.min.js > 1.11.2
https://ajax.googleapis.com/ajax/libs/jquery/1-11-2/jquery.min.js > NULL
https://ajax.googleapis.com/ajax/libs/jquery/1112/jquery.min.js > NULL
https://www.google.com/recaptcha/api.js?render=6LdBsjgVaoTJ8rC-Npzz16bnAE > NULL

My regEx: /([0-9]+\.?)+/

Thank you in advance for your help :)

4
  • 2
    What do you exactly want to do? please clarify your problem. Commented Jun 8, 2021 at 17:46
  • 1
    @AdisonMasih I would like to get versions from links as shown on the example of several links. I gave the arrow to illustrate what to download from the link Commented Jun 8, 2021 at 17:51
  • My current regEx does not work as it needs because it selects every number and not so many which should be because, for example, when I give a link to recaptcha, it selects values ​​from the key and should not return anything Commented Jun 8, 2021 at 17:53
  • @Wiktor Answered Your Question Already :) Commented Jun 8, 2021 at 17:54

1 Answer 1

2

You can use

\/(?:v(?:ersion)?-?)?\K\d+(?:\.\d+)+

See the regex demo. NOTE: if you want to make sure after the version number there is a / or end of string, add a (?![^\/]) lookahead at the end of the pattern, \/(?:v(?:ersion)?-?)?\K\d+(?:\.\d+)+(?![^\/]) (see this regex demo).

Details:

  • \/ - a / char
  • (?:v(?:ersion)?-?)? - an optional sequence of a v and then an optional ersion and then an optional - char - \K - omit the matched text
  • \d+(?:\.\d+)+ - match and consumer one or more digits and then one or more sequences of a dot and one or more digits.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.