Update sp.py

Simplification using regexs.