a regular expression for <......./>

T

Tony

Hi,

I would like to replace any word in a document with the following
pattern with an empty string. What should I set to
Selection.Find.Text? Could anybody kindly help me out? Many thanks.

<......./> where ...... means anything

Tony
 
D

dedawson

No VBA required for this one either. Use Search and Replace with wild
cards.
Find what = (\<)([!/\>]{1,255})(/\>)
Note that the \ characters in the search string are required to
'quote' the reserved characters < and >
Note also that this will fail if there are more than 255 characters
between < and />

What the search string is essentially saying is:
Find a string beginning with <, followed by up to 255 characters that
aren't />, followed by />

To see how to do this programatically, see:
http://groups.google.com/group/micr...eneral/browse_thread/thread/0708f086724a24a1#
 
D

dedawson

A little more thought led me to (still using wildcards):

Find what = (\<*/\>)

In this case there's no 255 character limit.
Be careful though, as this will work across paragraphs.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top