Macro for intelligent wildcard pattern modification


S

sandeep6699

Greetings,

I have a need to do some intelligent wildcard pattern modification, and I am looking for a WORD macro to do that. Basically I am looking for something along these lines:

I have three patterns: pr00f2.html, pr0418.html and pr6849.html. I can specify these patterns using the wildcard pr*.html. I would like to be able to add a prefix or suffix to all such patterns. Thanks in advance.

TIA,
Sandeep
 
Ad

Advertisements

A

Auric__

sandeep6699 said:
I have a need to do some intelligent wildcard pattern modification, and
I am looking for a WORD macro to do that. Basically I am looking for
something along these lines:

I have three patterns: pr00f2.html, pr0418.html and pr6849.html. I can
specify these patterns using the wildcard pr*.html. I would like to be
able to add a prefix or suffix to all such patterns. Thanks in advance.
What *exactly* do you mean by "prefix or suffix"? Give some examples of what
you want to match, and some you *don't* want to match.
 
S

sandeep6699

What *exactly* do you mean by "prefix or suffix"? Give some examples of what

you want to match, and some you *don't* want to match.
Let us say I have three patterns in my text file: pr00f2.html, pr0418.html and pr6849.html. I can specify these patterns using the wildcard pr*.html.

Case 1 (prefix, prefix-pattern ABC):
pr00f2.html ----> ABCpr00f2.html
pr0418.html ----> ABCpr0418.html
pr6849.html ----> ABCpr6849.html


Case 2 (suffix, suffix-pattern XYZ):
pr00f2.html ----> pr00f2.htmlXYZ
pr0418.html ----> pr0418.htmlXYZ
pr6849.html ----> pr6849.htmlXYZ


Case 3 (prefix+suffix):
pr00f2.html ----> ABCpr00f2.htmlXYZ
pr0418.html ----> ABCpr0418.htmlXYZ
pr6849.html ----> ABCpr6849.htmlXYZ


Hope that helps!
SS
 
Ad

Advertisements

A

Auric__

sandeep6699 said:
Let us say I have three patterns in my text file: pr00f2.html,
pr0418.html and pr6849.html. I can specify these patterns using the
wildcard pr*.html.

Case 1 (prefix, prefix-pattern ABC):
pr00f2.html ----> ABCpr00f2.html
pr0418.html ----> ABCpr0418.html
pr6849.html ----> ABCpr6849.html
Depends on the prefix, I suppose. If you're matching, say, a literal "ABC",
then this would work:

prefix$ = "ABC"
result$ = DIR$(prefix$ & "pr*.html")

On the other hand, if it's any three characters, this should work:

prefix$ = "???"
result$ = DIR$(prefix$ & "pr*.html")

("?" will match any single character; therefor "???" matches any 3
characters.)

If you need to match a more specific pattern, you *might* need to deal with
that in code, depending on what is being looked for.
Case 2 (suffix, suffix-pattern XYZ):
pr00f2.html ----> pr00f2.htmlXYZ
pr0418.html ----> pr0418.htmlXYZ
pr6849.html ----> pr6849.htmlXYZ
Similar to the above.

suffix$ = "XYZ" 'or "???"
result$ = DIR$("pr*.html" & suffix$)
Case 3 (prefix+suffix):
pr00f2.html ----> ABCpr00f2.htmlXYZ
pr0418.html ----> ABCpr0418.htmlXYZ
pr6849.html ----> ABCpr6849.htmlXYZ
Combine the two above.

prefix$ = "ABC" 'or "???" or whatever
suffix$ = "XYZ" 'or "???" or whatever
result$ = DIR$(prefix$ & "pr*.html" & suffix$)

This should be an acceptable general-purpose version here. If you don't need
a prefix or suffix, asign an empty string ("") to the appropriate variable.
 

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