PDA

View Full Version : Solved: Find and Replace Problem



r054
02-22-2008, 11:46 AM
Hi,

I'm using find and replace to find a certain pattern in the document. Is it possible to have an optional character in find and replace? In normal regular expression ? (question mark ) is used to indicate if the character is optional. But I'm not sure how to do it in find and replace.

This is what I have:
.Text = ".,page .#[0-9a-z]{1,}^13"
The period in the beginning and before the # symbol are optional. It should find the sentence even if the period (.) symbols are not there.

I've tried this one but didn't work
.Text = "[.]{0,},page [.]{0,}#[0-9a-z]{1,}^13"
Any help would be appreciated.

Tinbendr
02-22-2008, 02:58 PM
Yes the ? is for any single character.

But, I have to admit, I'm terrible at wildcard patterns, so I always refer to this page (http://word.mvps.org/faqs/general/UsingWildcards.htm). (Even then I usually have to ask for additional help.)

Good luck!

senthilkumar
02-22-2008, 08:55 PM
@r054,

I

senthilkumar
02-22-2008, 08:56 PM
@r054,

Ok.

senthilkumar
02-22-2008, 08:58 PM
@r054,

ok, fine. i want to know is any other charectar will appear in the plalce of period?

Thanks,
S. Senthil Kumar.

TonyJollans
02-23-2008, 12:33 PM
Word F&R doesn't really handle optional characters in the way you want. {0,} would be the way to do it but it doesn't work.

You could try using a pattern that would also find some other combinations that you may not have, for example:

[.,]{1,2} should find . or , or .. or ,, or ., or ,.

If you never had (or were happy to find) the others it might work for you