Add [] around numbers

A

Aki

Hi all,

I have a Word document and there are a lot of numbers in it. I want to use
Find and Replace to add [] around each of them, for example 12 --> [12] or
12.5 --> [12.5]. How should I do it?

Thanks a lot.
 
K

Klaus Linke

I have a Word document and there are a lot of numbers in it.
I want to use Find and Replace to add [] around each of them,
for example 12 --> [12] or 12.5 --> [12.5]. How should I do it?


Hi Aki,

Hasn't this been answered somewhere else? If not:

"Edit > Replace", check "More > Match wildcards",
Find what: <[0-9.]{1,}
Replace with: [^&]

[0-9.] matches any number or the (decimal) point,
[0-9.]{1;} matches as many as possible (up to 255 I think) of those.
"<" makes sure that it only matches at the beginning of a "word", and so
doesn't match numbers in text (Word2000, H2O...).
^& re-inserts the matched text.

If you use a non-English version (German, Dutch...), you may have to use
{1;} instead of {1,}.

Regards,
Klaus
 
A

Aki

Hi Klaus,

Thank you very much for your response, it works really well. I did post the
same message several times, at first it didn't seem go through. So I posted
it several more times and I also got response from other person with
different solution which use Macro. But Yours is much simpler and easy to
use. Thanks again.

Aki

“Klaus Linkeâ€ç¼–写:
I have a Word document and there are a lot of numbers in it.
I want to use Find and Replace to add [] around each of them,
for example 12 --> [12] or 12.5 --> [12.5]. How should I do it?


Hi Aki,

Hasn't this been answered somewhere else? If not:

"Edit > Replace", check "More > Match wildcards",
Find what: <[0-9.]{1,}
Replace with: [^&]

[0-9.] matches any number or the (decimal) point,
[0-9.]{1;} matches as many as possible (up to 255 I think) of those.
"<" makes sure that it only matches at the beginning of a "word", and so
doesn't match numbers in text (Word2000, H2O...).
^& re-inserts the matched text.

If you use a non-English version (German, Dutch...), you may have to use
{1;} instead of {1,}.

Regards,
Klaus
 

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