Try to search your question here, if you can't find : Ask Any Question Now ?

Regex pattern to extract version numbers from string

HomeCategory: stackoverflowRegex pattern to extract version numbers from string
sourav asked 2 weeks ago

I am trying to extract version numbers from a string pattern like this

“FasterXML jackson-databind through 2.8.10 and 2.9.x through 2.9.3 allows unauthenticated remote code execution because of an incomplete fix for the CVE-2017-7525 deserialization flaw. This is exploitable by sending maliciously crafted JSON input to the readValue method of the ObjectMapper, bypassing a blacklist that is ineffective if the Spring libraries are available in the classpath.”

Note that version number can contain variants like
2.8.x
2.8
2

and I would want to extract all of them

I need to check this string to verify if my current version matches upto the version specified in the string

val str = "FasterXML jackson-databind through 2.8.10 and 2.9.x through 2.9.3 allows unauthenticated remote code execution because of an incomplete fix for the CVE-2017-7525 deserialization flaw. This is exploitable by sending maliciously crafted JSON input to the readValue method of the ObjectMapper, bypassing a blacklist that is ineffective if the Spring libraries are available in the classpath."
str: String = "FasterXML jackson-databind through 2.8.10 and 2.9.x through 2.9.3 allows unauthenticated remote code execution because of an incomplete fix for the CVE-2017-7525 deserialization flaw. This is exploitable by sending maliciously crafted JSON input to the readValue method of the ObjectMapper, bypassing a blacklist that is ineffective if the Spring libraries are available in the classpath."

val numbers = """"\d+(\.\d+\.\d+)+""".r
1 Answers
Best Answer
naveen answered 2 weeks ago
Your Answer

4 + 7 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com