I have a version regex which works in PCRE format while am having trouble getting this to work with sed using match groups.
Regex:
((^[[:alnum:]]+.*)-(\d+\.\d+\.\d+-VERS|\d+\.\d+\.\d+))
Input:
aaa1-bbb2-ccc3-dddd4-ffff5-1.0.0-VERS
aaa1-bbb2-ccc3-dddd4-ffff5-11.22.33-VERS
zzz1-bbb2-ccc3-1.0.1
zzz1-1.0.1-VERS
expected output: split strings and separate the version string
group2="aaa1-bbb2-ccc3-dddd4-ffff5"
group3="1.0.0-VERS"
group2="aaa1-bbb2-ccc3-dddd4-ffff5"
group3="11.22.33-VERS"
group2="zzz1-bbb2-ccc3"
group3="1.0.1"
group2="zzz1"
group3="1.0.1-VERS"
The above output work as expected here
However, trying to use the same version with sed does not work. What am I missing?
echo "aaa1-bbb2-ccc3-dddd4-ffff5-11.22.33-VERS" | sed -E 's#((^[[:alnum:]]+.*)-(\d+\.\d+\.\d+-VERS|\d+\.\d+\.\d+))#\3 \2#p'