Wildcard expression?

R

RedRado03

I am writing a probgram that searces for acronyms. I was wondering what the
wildcard expression would be to search for whole words that contained
characters such as: - or / for example:

Door-Mat123 or help/please

I am using a second criteria to identify it as a acronym based off the
microsoft word selection.

My search criteria can select Door then Mat123 but, not all as one
selection. Is there a way to write this? This is what I have.

Need to include the dashes and slashes within a word.

<([A-Za-z0-9][A-Za-z0-9]*)>
 
J

Jay Freedman

This search term will find the expressions you listed:

<([A-Za-z0-9][A-Za-z0-9/-]{1,})>

Notice a couple of things:

- You can include the hyphen in a character range by listing it last;
otherwise it's assumed to connect the start and end of a range.

- There's no problem with including a forward slash in a character range. A
backslash or any other special character would need to be preceded by a
backslash -- see item 5 in
http://word.mvps.org/FAQs/General/UsingWildcards.htm.

- Using {1,} instead of * causes the search to use "greedy" matching, so it
doesn't stop on finding Door but continues until it finds Door-Mat123.

- If you immediately search again, the same search will find the second part
of the combination (Mat123). To avoid this, set up your code at the end of
each iteration to move the start of the search range to the end of the most
recently found occurrence.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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