If you thought grep was powerful, wait until you get a hold of ast-grep, which takes it to a whole new level.
The compiler analyzed it, optimized it, and emitted precisely the machine instructions you expected. Same input, same output.