I am currently using the following relevance to extract the Java version from RPM packages:
bigfix
(name of it & " - " & version of it as string) of packages whose (name of it as lowercase starts with "java-") of rpm
Example Output:
java-1.8.0-openjdk-headless - 1.8.0.432.b06-2.el8
However, I need to extract and display the Java version in a simpler format, like Java-1.8.0 or Java-1.9.0, without including additional parts like -headless or other suffixes in the version string.
Goal: Output should look like:
Java-1.8.0
Java-1.9.0
Suggestions:
How can I modify the above query to display just the major, minor, and patch version (e.g., 1.8.0 or 1.9.0)? I would appreciate any suggestions or improvements to this query.
unique values of (matches (regex "java-([0-9]\.[0-9]\.[0-9])") of ((name of it & " - " & version of it as string) of packages whose (name of it as lowercase starts with "java-") of rpm))type or paste code here
Using a test VM I have with your original expression following by the one above.
Q: (name of it & " - " & version of it as string) of packages whose (name of it as lowercase starts with "java-") of rpm
A: java-1.8.0-openjdk - 1.8.0.402.b06-1.el7_9
A: java-1.7.0-openjdk-headless - 1.7.0.261-2.6.22.2.el7_8
A: java-1.8.0-openjdk-headless - 1.8.0.402.b06-1.el7_9
A: java-1.7.0-openjdk - 1.7.0.261-2.6.22.2.el7_8
T: 2153051
Q: unique values of (matches (regex "java-([0-9]\.[0-9]\.[0-9])") of ((name of it & " - " & version of it as string) of packages whose (name of it as lowercase starts with "java-") of rpm))
A: java-1.7.0
A: java-1.8.0
T: 6312
Or maybe you were after the truncated package name and the full version info? You can move the regex to accomplish that
Q: unique values of ((match (regex "java-([0-9]\.[0-9]\.[0-9])") of name of it & " - " & version of it as string) of packages whose (name of it as lowercase starts with "java-") of rpm)
A: java-1.7.0 - 1.7.0.261-2.6.22.2.el7_8
A: java-1.8.0 - 1.8.0.402.b06-1.el7_9
T: 6258