Input string could be any of the below strings.
image: xyz.com/elk_init_cos7:1.0.0-20.12.0
image: "xyz.com/ckaf/kafka:4.1.0-5.4.1-59"
import re
mat = re.search("image:\s*\"?(.+?/(.+?):(.+?))\"?", str)
if mat:
print (mat.group(1))
print (mat.group(2))
print (mat.group(3))
Ouptut:
artifactory.net.nokia.com/ckaf/kafka:4
ckaf/kafka
4
If I use regex as "image:\s*"?(.+?/(.+?):(.+))"?", then I am getting the string with double quote 4.1.0-5.4.1-59".
How can I get last part of the string without " coming at end and still satisfy other input string also?