in reply to close end tag

Hi gem,

If you want to use the pattern above you need to correct your regular expression.

you are matching:

<a # begin anchor tag \s # followed by a space \w* # followed by any number of alpha-numeric characters # this fails to match ["'=/:%?&] and probably many other potential + permissable chars in this context and so your regex fails here. > # 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
You are replacing your match with just an end of anchor tag, you need to capture what you match (possibly two distinct matches or a lookahead to check for end of anchor) and insert the end of anchor there.

You have the basis of a tolerable regex but it needs finishing.

Try and implement the above and let us know how you get on