Find and Replace

jec
Lounger
Posts: 29
Joined: 03 Oct 2011, 01:44

Find and Replace

Post by jec »

Hi everyone
Wish to Find and Replace:

Find: any string “index [0000]”
up to 4 manual digits in square brackets and bold
Replace: with Field code sequence:
index [{ SEQ Index \* Arabic \* CHARFORMAT }]
I am using ^c
to perform field code replace

Text to search for may be example index [1] and index [2]. Is index [3] and up to index [1000] end sentence.

Please.

Also require to search manual numbering:
(a)
(b)
throughout document which will use Heading 4 outline numbering.
Sequence for search pattern would be appreciated. I need to mark entire document for (a) onwards and turning into outline numbering Heading 4.
I know it can be done I just cannot get Find sequence correct.

Any help appreciated.
:hairout:

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Find and Replace

Post by HansV »

1) Press Ctrl+H.
Enter index \[[0-9]{1,4}\] in the Find what box. The \ tell Word that the following [ or ] is a literal character to be found instead of a special code.
Enter ^c in the Replace with box.
Click More >>.
Tick the Use wildcards box.
Click Replace All.
Best wishes,
Hans

User avatar
macropod
4StarLounger
Posts: 508
Joined: 17 Dec 2010, 03:14

Re: Find and Replace

Post by macropod »

Just to add to what Hans says, the copied expression for the ^c should be:
index [{ SEQ Index \* Arabic \* CHARFORMAT }]
You can't just copy the field code with his F/R approach. Alternatively, you could copy just the field code if the F/R expression is:
Find = (index \[)[[0-9]{1,4}(\])
Replace = \1^c\2
Paul Edstein
[Fmr MS MVP - Word]

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Find and Replace

Post by HansV »

2) For the other: you can use (^$) without wildcards, or \([a-z]\) with wildcards to search for (a), (b) etc.
Best wishes,
Hans

jec
Lounger
Posts: 29
Joined: 03 Oct 2011, 01:44

Re: Find and Replace

Post by jec »

Thank you Hans and Paul. Both do what I want.

Hans the convert manual numbers

(a)
(b)
(aa) etc
Level 3
Does not delete (a) manual level number first.

What I am looking for is manual numbering
1.
2.
Convert to Headling 1 or any style to apply auto numbering and delete the manual number and period.

(a)
(b)
(aa)
etc
And delete the manual numbering and replace with a style for autonumbering.

(i)
(ii)
etc

And
(A)
(B)
etc

(1)
(2)
(3)
etc.

The (a) etc could be at any manual level in the document and I would need to restart after my global replace. But not in a paragraph just at the beginning - same for all levels. The manual number would be at beginning of the paragraph not in the paragraph itself.

Thank you both so much. You help is much appreciated.

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Find and Replace

Post by HansV »

I think I'd do this in two steps:

First, use Replace to apply the appropriate Heading style to paragraphs beginning with (a), (i) etc.
Perform a visual check that it has been applied correctly.

Then, go through the document again to delete the manual numbering. You could do this manually (press Shift+F4 or Ctrl+PgDn to find the next instance, press Delete, etc. etc.) or write a macro for it. If your text could contain other instances of (...) you'd have to be careful.
Best wishes,
Hans

jec
Lounger
Posts: 29
Joined: 03 Oct 2011, 01:44

Re: Find and Replace

Post by jec »

Hi Hans
I've seen it done, hence my persistence.
I do not want to find number sequence, for example "(a)", inside a paragraph just at the beginning of a paragraph or whatever number sequence be it 1. (i), (1) or (A). Is there a way to search for the manual number sequence only if it appears at beginning of a paragraph.
I was hoping then to selects it, delete it and apply the style. You are write I will put it in a macro but I've seen it done with Find and Repace dialogue windows.

Thank you Hans much appreciate your help.

User avatar
HansV
Administrator
Posts: 78628
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Find and Replace

Post by HansV »

Perhaps someone else will have a bright suggestion - I don't know how to do the whole thing with Find/Replace only.
Best wishes,
Hans

jec
Lounger
Posts: 29
Joined: 03 Oct 2011, 01:44

Re: Find and Replace

Post by jec »

Yes, I'm trying to figure it out also. Thanks Hans

User avatar
Guessed
2StarLounger
Posts: 102
Joined: 04 Feb 2010, 22:44
Location: Melbourne Australia

Re: Find and Replace

Post by Guessed »

If you are only using a series of search and replaces, then this solution is going to eventually get there.
To replace the (letter) list series with a style and remove the manual list numbers search for the following with Wildcards on
FIND - ^013\([a-z]{1,2}\)^t
REPLACE - ^pzzLISTzz

Then,
FIND - zzLISTzz
REPLACE - Nothing but add the Style to the replace formatting

Then run the second replace again with the style turned off.

The same principle could be applied to the other list types. Note that the sublist using roman numerals will also get this style setting so you will need a much trickier pattern match to avoid that.
Andrew Lockton
Melbourne Australia

jec
Lounger
Posts: 29
Joined: 03 Oct 2011, 01:44

Re: Find and Replace

Post by jec »

Hi Guessed
I don't get any result with the Find/Replace on the first option?
0 replacements.

I attach a draft test document.

It should work. It is looking for (a) to (aaa) or whatever with a tab at beginning of paragraph and replace with xxxxx and then run the replace again to apply the heading level style.

Thank you for helping.
You do not have the required permissions to view the files attached to this post.

User avatar
Guessed
2StarLounger
Posts: 102
Joined: 04 Feb 2010, 22:44
Location: Melbourne Australia

Re: Find and Replace

Post by Guessed »

Looking at the text in your document, it appears you left the backslashes out of the first Find string. Do you want to try it again with those in there?
Andrew Lockton
Melbourne Australia

jec
Lounger
Posts: 29
Joined: 03 Oct 2011, 01:44

Re: Find and Replace

Post by jec »

Yes Guessed all works.
Thank you everyone.