Wildcard Search and Replace

J

Johann Swart

I have "inherited" a set of documents that exhibit a rather strange behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I want
to change these to ABC / DEF (i.e.
Code:
[hardspace][forward
slash][hardspace][code]). In the Word Search and Replace I select Use
Wildcards. I then enter in the Find What line: ([A-Z]{3})/([A-Z]{3}) and in
the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the result is
as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem
obviously lies with the document itself and not the PC or Word. Has anyone
any idea what is going on here and how one can remedy this peculiarity?
 
J

Johann Swart

Yes, there are many other slashes in this document to which this exercise
does not apply.

grammatim said:
Is there a reason not to simply Replace slash with space slash space ?

I have "inherited" a set of documents that exhibit a rather strange behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I want
to change these to ABC / DEF (i.e.
Code:
[hardspace][forward
slash][hardspace][code]). In the Word Search and Replace I select Use
Wildcards. I then enter in the Find What line: ([A-Z]{3})/([A-Z]{3}) and in
the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the result is
as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem
obviously lies with the document itself and not the PC or Word. Has anyone
any idea what is going on here and how one can remedy this peculiarity?[/QUOTE]
[/QUOTE]
 
T

Tony Jollans

There is a bug (fixed in Word 2007) that causes this to happen when Track
Changes is on. Try switching off Track Changes before your Replace and the
turning it back on afterwards.
 
M

macropod

Hi Johann,

You could perhaps try:
(<[A-Z]{3})(/)([A-Z]{3}>) as the Find, with
\1 \2 \3 as the Replace.
Note: the < and > prevent the Find from processing strings of 4 or more letters.
 
M

macropod

Or, for hard spaces in the replacement:
\1^s\2^s\3

--
Cheers
macropod
[Microsoft MVP - Word]


macropod said:
Hi Johann,

You could perhaps try:
(<[A-Z]{3})(/)([A-Z]{3}>) as the Find, with
\1 \2 \3 as the Replace.
Note: the < and > prevent the Find from processing strings of 4 or more letters.

--
Cheers
macropod
[Microsoft MVP - Word]


Johann Swart said:
I have "inherited" a set of documents that exhibit a rather strange behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I want to change these to ABC / DEF (i.e.
Code:
[hardspace][forward slash][hardspace][code]). In the Word Search and Replace I select Use Wildcards. I then enter in the
Find What line: ([A-Z]{3})/([A-Z]{3}) and in the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the result is as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem obviously lies with the document itself and not the PC or
Word. Has anyone any idea what is going on here and how one can remedy this peculiarity?[/QUOTE][/QUOTE]
 
T

Tony Jollans

.. which will still suffer at the hands of the same bug.

--
Enjoy,
Tony

www.WordArticles.com

macropod said:
Or, for hard spaces in the replacement:
\1^s\2^s\3

--
Cheers
macropod
[Microsoft MVP - Word]


macropod said:
Hi Johann,

You could perhaps try:
(<[A-Z]{3})(/)([A-Z]{3}>) as the Find, with
\1 \2 \3 as the Replace.
Note: the < and > prevent the Find from processing strings of 4 or more
letters.

--
Cheers
macropod
[Microsoft MVP - Word]


Johann Swart said:
I have "inherited" a set of documents that exhibit a rather strange
behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I
want to change these to ABC / DEF (i.e.
Code:
[hardspace][forward
slash][hardspace][code]). In the Word Search and Replace I select Use
Wildcards. I then enter in the Find What line: ([A-Z]{3})/([A-Z]{3}) and
in the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the
result is as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem
obviously lies with the document itself and not the PC or Word. Has
anyone any idea what is going on here and how one can remedy this
peculiarity?[/QUOTE][/QUOTE]
[/QUOTE]
 
M

macropod

Perhaps so. It could be that the inherited document is corrupt, or maybe there's an ADVANCE field or something such taking effect
when a space is inserted between the strings..

--
Cheers
macropod
[Microsoft MVP - Word]


Tony Jollans said:
.. which will still suffer at the hands of the same bug.

--
Enjoy,
Tony

www.WordArticles.com

macropod said:
Or, for hard spaces in the replacement:
\1^s\2^s\3

--
Cheers
macropod
[Microsoft MVP - Word]


macropod said:
Hi Johann,

You could perhaps try:
(<[A-Z]{3})(/)([A-Z]{3}>) as the Find, with
\1 \2 \3 as the Replace.
Note: the < and > prevent the Find from processing strings of 4 or more letters.

--
Cheers
macropod
[Microsoft MVP - Word]


I have "inherited" a set of documents that exhibit a rather strange behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I want to change these to ABC / DEF (i.e.
Code:
[hardspace][forward slash][hardspace][code]). In the Word Search and Replace I select Use Wildcards. I then enter in the
Find What line: ([A-Z]{3})/([A-Z]{3}) and in the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the result is as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem obviously lies with the document itself and not the PC or
Word. Has anyone any idea what is going on here and how one can remedy this peculiarity?[/QUOTE]
[/QUOTE]
[/QUOTE]
 
J

Johann Swart

Hi TJ, you are 100% correct; I am using TC. And really, I should have guessed
this myself having had similar experiences with TC. I turned TC off and S&R
had the desired effect. Thanks a million for reminding me!

Tony Jollans said:
There is a bug (fixed in Word 2007) that causes this to happen when Track
Changes is on. Try switching off Track Changes before your Replace and the
turning it back on afterwards.

--
Enjoy,
Tony

www.WordArticles.com

Johann Swart said:
I have "inherited" a set of documents that exhibit a rather strange
behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I
want
to change these to ABC / DEF (i.e.
Code:
[hardspace][forward
slash][hardspace][code]). In the Word Search and Replace I select Use
Wildcards. I then enter in the Find What line: ([A-Z]{3})/([A-Z]{3}) and
in
the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the result
is
as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem
obviously lies with the document itself and not the PC or Word. Has anyone
any idea what is going on here and how one can remedy this peculiarity?[/QUOTE]
[/QUOTE]
 
T

Tony Jollans

It is not corruption. It is a bug in versions of Word prior to 2007. The
order of replacement literals and found groups is not honoured when Track
Changes is in effect.

--
Enjoy,
Tony

www.WordArticles.com

macropod said:
Perhaps so. It could be that the inherited document is corrupt, or maybe
there's an ADVANCE field or something such taking effect when a space is
inserted between the strings..

--
Cheers
macropod
[Microsoft MVP - Word]


Tony Jollans said:
.. which will still suffer at the hands of the same bug.

--
Enjoy,
Tony

www.WordArticles.com

macropod said:
Or, for hard spaces in the replacement:
\1^s\2^s\3

--
Cheers
macropod
[Microsoft MVP - Word]


Hi Johann,

You could perhaps try:
(<[A-Z]{3})(/)([A-Z]{3}>) as the Find, with
\1 \2 \3 as the Replace.
Note: the < and > prevent the Find from processing strings of 4 or more
letters.

--
Cheers
macropod
[Microsoft MVP - Word]


I have "inherited" a set of documents that exhibit a rather strange
behaviour.
In these documents three-letter codes are listed in the form ABC/DEF.
I want to change these to ABC / DEF (i.e.
Code:
[hardspace][forward
slash][hardspace][code]). In the Word Search and Replace I select Use
Wildcards. I then enter in the Find What line: ([A-Z]{3})/([A-Z]{3})
and in the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the
result is as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem
obviously lies with the document itself and not the PC or Word. Has
anyone any idea what is going on here and how one can remedy this
peculiarity?
[/QUOTE]
[/QUOTE]
[/QUOTE]
 
M

macropod

Ah, I see - I hadn't seen your separate reply to the OP.

Oddly, F/R works correctly when the Find text is itself marked as an addition. Deleted text is left alone if it's hidden, but gets
processed (with the same peculiar results you get for previously-unchanged text) if it's visible.

--
Cheers
macropod
[Microsoft MVP - Word]


Tony Jollans said:
It is not corruption. It is a bug in versions of Word prior to 2007. The order of replacement literals and found groups is not
honoured when Track Changes is in effect.

--
Enjoy,
Tony

www.WordArticles.com

macropod said:
Perhaps so. It could be that the inherited document is corrupt, or maybe there's an ADVANCE field or something such taking effect
when a space is inserted between the strings..

--
Cheers
macropod
[Microsoft MVP - Word]


Tony Jollans said:
.. which will still suffer at the hands of the same bug.

--
Enjoy,
Tony

www.WordArticles.com

Or, for hard spaces in the replacement:
\1^s\2^s\3

--
Cheers
macropod
[Microsoft MVP - Word]


Hi Johann,

You could perhaps try:
(<[A-Z]{3})(/)([A-Z]{3}>) as the Find, with
\1 \2 \3 as the Replace.
Note: the < and > prevent the Find from processing strings of 4 or more letters.

--
Cheers
macropod
[Microsoft MVP - Word]


I have "inherited" a set of documents that exhibit a rather strange behaviour.
In these documents three-letter codes are listed in the form ABC/DEF. I want to change these to ABC / DEF (i.e.
Code:
[hardspace][forward slash][hardspace][code]). In the Word Search and Replace I select Use Wildcards. I then enter in
the Find What line: ([A-Z]{3})/([A-Z]{3}) and in the Replace With line \1^s/^s\2.
The result is this (surprisingly!): ABCDEF /.
When I create a new test document to replicate this situation, the result is as expected, i.e. ABC / DEF.
Has anyone ever experienced a situation similar to this? The problem obviously lies with the document itself and not the PC
or Word. Has anyone any idea what is going on here and how one can remedy this peculiarity?
[/QUOTE]
[/QUOTE]
[/QUOTE]
 
P

PamC via OfficeKB.com

I'm so glad to hear that it's fixed in W2007. I can't tell you how many
times I've forgotten about that little nuisance and had to undo, turn off
track changes, and redo the sort.

Pam



Tony said:
It is not corruption. It is a bug in versions of Word prior to 2007. The
order of replacement literals and found groups is not honoured when Track
Changes is in effect.
Perhaps so. It could be that the inherited document is corrupt, or maybe
there's an ADVANCE field or something such taking effect when a space is
[quoted text clipped - 27 lines]
 

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