Search and replace with wildcards

  • Thread starter Thread starter Ben K. Bullock
  • Start date Start date
B

Ben K. Bullock

Using wildcards, when I try to find

(Fig.)([0-9]{1,})

and replace it with

\1 \2

instead of replacing "Fig.11" with "Fig. 11", it replaces "Fig.11" with
"Fig.11 " (with a space after the 11 rather than before it). I must be
missing something obvious, but what is it?

Thank you for any help with this problem.
 
It works fine here. Are you sure there isn't a space after \2 ?
I noticed when testing that the apparent spacing after 11 changes, making
the gap between it and " larger, though there is no physical space inserted.
Check with $B"y(B or CTRL+*

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
"Check with $B"y(B" should have read "Check with ¶"
Please use plain text for your messages in this forum.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

Graham said:
It works fine here. Are you sure there isn't a space after \2 ?
I noticed when testing that the apparent spacing after 11 changes,
making the gap between it and " larger, though there is no physical
space inserted. Check with $B"y(B or CTRL+*

Using wildcards, when I try to find

(Fig.)([0-9]{1,})

and replace it with

\1 \2

instead of replacing "Fig.11" with "Fig. 11", it replaces "Fig.11"
with "Fig.11 " (with a space after the 11 rather than before it). I
must be missing something obvious, but what is it?

Thank you for any help with this problem.
 
Graham Mayor said:
It works fine here. Are you sure there isn't a space after \2 ?

Yes, that was the first thing I checked.
I noticed when testing that the apparent spacing after 11 changes, making
the gap between it and " larger, though there is no physical space
inserted. Check with $B"y(B or CTRL+*

After my frustrating experiences with this on the original document, I tried
it out on a blank document to which I had inserted a little text (not from
the original document) and found that it worked correctly. Unfortunately I
can't provide the original document for perusal because of confidentiality,
but this may have been some kind of bug or problem with that document in
particular. I really don't understand how that could happen in one document
and not another, but I'm not an expert on MS Word at all.

Thanks for the help anyway.
 
It works fine for me here and now, but ...

I remember a thread a few weeks back where, under certain conditions,
replacement elements were used in the wrong order - at the time I could
reproduce it but can't remember the details.
 
Having realised that you are working with Japanese I think this issue may be
related to Japanese language options in Word - I will see if I can pin
anything down.

--
Enjoy,
Tony

Tony Jollans said:
It works fine for me here and now, but ...

I remember a thread a few weeks back where, under certain conditions,
replacement elements were used in the wrong order - at the time I could
reproduce it but can't remember the details.

--
Enjoy,
Tony

Ben K. Bullock said:
Using wildcards, when I try to find

(Fig.)([0-9]{1,})

and replace it with

\1 \2

instead of replacing "Fig.11" with "Fig. 11", it replaces "Fig.11" with
"Fig.11 " (with a space after the 11 rather than before it). I must be
missing something obvious, but what is it?

Thank you for any help with this problem.
 
Tony Jollans said:
Having realised that you are working with Japanese I think this issue may
be
related to Japanese language options in Word - I will see if I can pin
anything down.

In this case I wasn't working with Japanese. The other problem I've had
recently was with the Japanese "degrees centigrade" marks, which I wanted to
turn into Western "degrees" plus "C", but in this case it was just a problem
in English in an English language file. As I mentioned, it only happened
with that file. I should have tested it on another file but it was the first
time I had tried to use Microsoft Word regular expressions so I panicked and
asked about the problems here rather than carefully studying it.

I would be happy to present the original file which caused the problems here
for perusal but unfortunately a confidentiality agreement forbids this, so I
don't think there is anything much else to say about the topic unless I can
get a working example in another file. Without being able to show you the
problem-causing file I feel that I am sending you on a wild goose chase.

Thanks very much to everyone who tried to help. Next time I'll try to
reproduce the problems in a small sample file before requesting help here.
 
I was mistaken. The previous time I saw this - and I can still replicate
it - was in documents with Track Changes enabled. Not everyone experiences
it so there is some other factor but I don't, at the moment, know what it
is.

I don't know how (at least not easily) to add a link to another thread but
for reference I came across this in a post in
microsoft.public.word.docmanagement newsgroup, dated 23 Feb, from indeego,
and titled "Word Bug: Find/Replace wildcard while track changes turned on is
buggy"
 
Tony Jollans said:
I was mistaken. The previous time I saw this - and I can still replicate
it - was in documents with Track Changes enabled. Not everyone experiences
it so there is some other factor but I don't, at the moment, know what it
is.

Thank you very much for that insight. I went back to the original document
and tried again with "track changes" turned off, and found that now it does
work correctly, with the space between the Fig. and the number being
inserted correctly. So I assume it's a bug in Word. What is a good
workaround for this kind of bug? If I turn off track changes and do the
change, is it possible to then get the changes recorded?

Anyway, thank you again for your insight.

This newsgroup is a great source of extremely valuable information.
 
Back
Top