Do I have #regex experts among my followers: echo "123.4506000" | sed -E 's/(\.[0-9]*[1-9])?0+$//; s/\.$//' is intended to remove trailing 0s when its a number with a decimal point. But when there are no cifers behind the decimal point other than 0s, the whole number shall be stripped of the point and the 0s. What are I am doing wrong? Sharing appreciated.
@tschapajew Try this:
echo "123.4506000" | sed -E 's/\.?0+$//; s/(\.[0-9]*[1-9])0+$/\1/'
s/\.?0+$// removes .0000 with or without '.' at the end.
s/(\.[0-9]*[1-9])0+$/\1/
Strips trailing 0s only if there's at least 1 didget that isn't 0 before the 0s.
@fireborn Wow cool! Thanks. Works.
@fireborn Implemented. Mencioned you with thanks on my last commit: https://github.com/do9re/midi2hamlib
Hmm. Das Problem ist gelöst. Aber warum mit regulären Ausdrücken? Die sind sehr mächtig und daher in der ausführung teuer. Das problem ließe sich mit wenig code in jeder prozeduralen sprache lösen, die einen string-datentyp hat. Das wäre billiger.
Geht leider nicht, mein mastodon client darf externe links nur öffnen, wenn im wifi, nicht mobil.