1
votes

I've a problem when using Find. I want to find some patterns like the following:

  • ABC-0123 DEF
  • ABC-01234 DEF
  • ABC-012345 DEF
  • ABCD-0123 DEF
  • ABCD-01234 DEF

This patterns can be found everywhere in the text. In the beginning of a line, in the end or in the middle. In RegExp I can use like "[A-Z]{3,5}-[0-9]{4,6} DEF", but this is not working in Wildcards.

In my function right now it first searches for "[A-Z]{3}-[0-9]{4} DEF", this will result in that ABCD-0123 DEF will be found in A BCD-0123 DEF (there is no space between the A and B..).

What can I use as character to check if the string/pattern is found without any other character before? Will this work if it's the first string in at a line?

I'll give a full example. I'll have a Word document with a text like this:

The raspberry is the edible fruit of a multitude of plant species in the genus Rubus of the rose family, ABD-0123 DEF most of which are in the subgenus Idaeobatus; the name also applies to these plants themselves. Raspberries are perennial with woody stems. ABCD-01323 DEF

ABCD-011223 DEF have all the details inside.

This is how the text can look. I now want the Macro to find all the different patterns that I've mentioned above and make them Bold.

1
Your question is a bit difficult to parse... Please show us examples of what you want to find and what you don't want to find. - Jean-François Corbett
@Jean-FrançoisCorbett; please see my edit above - mr3k
Ok, and what about your examples of what you don't want to find?? (And what do you mean by "there is no space between the A and B.."? This is rather confusing. I suggest you reword the unclear bits in your question.) - Jean-François Corbett
@Jean-FrançoisCorbett; I've found a solution for this. But is there anyway to check if there are any character before the Pattern. So that when go for pattern ABC-1234 Def not finds in EABC-1234 Def because there are an "E" before the pattern? - mr3k
@Jean-FrançoisCorbett; I've solved it and posted solution below. Thanks. - mr3k

1 Answers

2
votes

SOLUTION

The solution was that I could use the same as for RegExp with "[A-Z]{3,5}-[0-9]{4,6} DEF", just that I needed to replace the comma "," with semi-colon ";".

Answer: "[A-Z]{3;5}-[0-9]{4;6} DEF"

To make sure the pattern isn't in the middle of a word you can use the "<".

My full solution:

"<[A-Z]{3;5}-[0-9]{4;6} DEF"