Remove line from history with grep

Today I needed to clear history from some command. I looked into history and used grep to filtering command I needed.

for i in $(history | grep something | grep -oE "[0-9]{1,} " | sort -rn); do history -d ${i}; done