I am a beginner in Regex but I am trying to implement it. What I am trying to do is I want to extract the links that are present in specific files via regex and print them out. Below are the links all in one place that I want to extarct:
https://ci.adoptopenjdk.net/view/Test_openjdk/job/openjdk8_hs_openjdktest_s390x_linux/18/consoleFull
https://ci.adoptopenjdk.net/view/Test_openjdk/job/Test_openjdk11_hs_sanity.openjdk_x86-64_mac/26/consoleFull
To reproduce: https://ci.adoptopenjdk.net/job/Test_openjdk14_hs_sanity.openjdk_ppc64_aix/111/console
Jenkins Build URL: https://ci.adoptopenjdk.net/job/Test_openjdk8_hs_extended.system_ppc64le_linux/259/
internal build `Test_openjdk8_j9_sanity.openjdk_aarch64_linux/43/`
internal build `Test_openjdk11_j9_sanity.functional_aarch64_linux/46`
I want the links in the form of (Expected):
https://ci.adoptopenjdk.net/view/Test_openjdk/job/openjdk8_hs_openjdktest_s390x_linux/18/
https://ci.adoptopenjdk.net/view/Test_openjdk/job/Test_openjdk11_hs_sanity.openjdk_x86-64_mac/26/
https://ci.adoptopenjdk.net/job/Test_openjdk14_hs_sanity.openjdk_ppc64_aix/111/
Test_openjdk8_j9_sanity.openjdk_aarch64_linux/43/
To solve it I tried to apply regex concept and came up with this pattern:
(?:(?:http|ftp|https):\/\/ci.adoptopenjdk.net.+(?:consoleFull|console|\d?))|(?:\`.+?\`)
But the output comes like this (Actual):
https://ci.adoptopenjdk.net/job/Test_openjdk17_j9_sanity.openjdk_x86-64_linux/33/consoleFull
https://ci.adoptopenjdk.net/view/Test_openjdk/job/openjdk8_hs_openjdktest_s390x_linux/18/consoleFullhttps://ci.adoptopenjdk.net/job/Test_openjdk11_hs_sanity.openjdk_ppc64_aix/145/`Test_openjdk8_j9_sanity.openjdk_aarch64_linux/43/`
`cent7-aarch64-3``Test_openjdk8_j9_sanity.openjdk_aarch64_linux/43/`
`cent7-aarch64-3`
Now I wanted to check on the basis of https://....Test_openjdk{num} as ci.adoptopenjdk.net is outdated
To encounter this situation I made a regex pattern to check all the links as mentioned above as inputs on the basis of Test_openjdk{num} to get the desired output.
I used
(?:http|ftp|https):\/\/Test_openjdk/\d.+\/(?=console)|(?<=\`).+?\/(?=\`)
but only got the following output:
Test_openjdk8_j9_sanity.openjdk_aarch64_linux/43/
Test_openjdk8_j9_sanity.openjdk_aarch64_linux/43/
I have been trying various ways but they all are failing. Can anyone explain me where and why am I going wrong it would really be great. Thank You