Like here: http://stevehanov.ca/blog/index.php?id=115 Which should make it possible to efficiently match locations inside of surrounding text.