On Mon, Feb 10, 2025 at 11:46 PM microsuxx <fxmb...@gmail.com> wrote:
> a bit unrelated .. cheap numbers filter .. > > gimme_num( ) { declare -n b=BASH_REMATCH\[1] ; local o m=[0-9,.] s=$n i t ; > t="(-?$m+)" ; unset -v o ; for n ; do unset -v i ; while [[ $n =~ $t ]] ; > do n=${n/"$b"} i= o+=$b$s ; done ; [[ -v i ]] && o+=$s ; done ; [[ -v o ]] > && printf %s "$o" ; } > > gimme_num ' ab3.44 cd---.99 ' cd cd 77.7.77 > > 3.44 > -.99 > > 77.7.77 > > Rejected $ gimme_num '0x10' 0x10xx $ gimme_num '64#yo' 64xx $ gimme_num '0x10' 0#yo10#yo#yo gimme_num should be renamed random_string()