Case Scenerio:
Variable or Array
var=( 002.20 20.020 20.002000 00200 20.02 .020)
for f in ${var[@]}; do echo ${f}; done
Output: 2.2 20.02 20.002 200 20.02 .02
Trying to achive this using pure bash that with help of $BASH_REMATCH capture groups
Tried:
eg.
f=20.0000210
[[ $f =~ ([0-9]?\.?0?[1-9]?)(0*$) ]]
echo ${BASH_REMATCH[@]}
210 21 0
Expected:
echo ${BASH_REMATCH[@]
20.000021 0
Can anyone help with this. Please. After debugging it seems bash capture groups are behaving unusually. I dont know how BASH_REMATCH works but from online tutorials i have seen that using () we can split string into BASH_REMATCH array. But something odd with splitting
oK after some debugging it appears unusual behaviour is due to cygwin bash. eg var=0002; echo ${var##0} or echo ${var##+(0)} doesnt work as expected