Do not use preg function here, it's way too slow.
avoid using string offsets
Generate a base URL once outside of the results loop since instead of on each iteration. Also, a lot of other cleanup.
tab to space
Merge pull request #5154 from okonomiyaki3000/dont-use-preg

Do not use preg function here, it's way too slow.