#!/bin/bash

for s in abcdefghijklmnop _test_ 123abc A_b1C_23 _! magical\ pony1; do
	echo -n "$s" | perl -pe '$_=!/\W|^\d//2**/^_/'
	echo
done