Transform snake_case to camelCase with sed
Why try to match for (^|_)? You are anyway modifying it at the end, so just skip the first character entirely:

echo "my_long_variable" | sed -r 's/_([a-z])/\U\1/gi' | sed -r 's/^([A-Z])/\l\1/'


The above pattern will take care of cases where you start with:

Some_var_Iable