I see a couple ways to do this in a more robust way:

1) request json format: https://github.com/Wikia/app/blob/dev/extensions/wikia/LinkSuggest/LinkSuggest.class.php#L237
2) implement a format "array" in the getLinkSuggest function and avoid processing text at all