Git does not use regexp but glob pattern to match ignored files. Add the following line in your root .gitignore:
[0-9]*
If you only want to ignore those files in the /static/img/ subdirectory you should either add the previous line to .gitignore file inside that subdirectory or add the following line in your root .gitignore:
/static/img/[0-9]*