# end anchor tag \w* # any text as long as it's all one word see above point you should be matching any char which is not the beginning of a tag < # beginning of a new tag including an end of anchor