using wildcards in word

Copper Contributor

Hello!

I need to change decimal character from dot to comma in document in all the numbers. The expression i use for this

FIND: ([0-9]{1;}).

REPLACE: \1

it works but in my mother tongue Latvian we use "." ( a dot) after the number of the year. For instance:

From the year 2000. gads until year 2003. (gads)  we were in the relationship. (gads) is Year from Latvian. When I use 2000 in the sentence i should obligatory use "gads" which Is "year"

So when I Apply this function in my document sentence changes to:

From the year 2000, until year 2003, we were in the relationship. 

Which is incorrect.

How do I put limitation to the function, so only numbers like 0.8 and 5.6% change their decimals?

 

my question is: how to put 

 

5 Replies

Hi @daniils21,

if I understood the question correctly, this is my solution:

FIND: ([0-9]{1;}[.,])(?![0-9]|[a-zA-Z])

REPLACE: \1

This pattern will match numbers followed by a dot or comma, but only if they are not followed by another number or a letter. By using this pattern, the decimal character will only be replaced in numbers that are not immediately followed by another number or letter.


Applying this pattern to your example sentence:

"From the year 2000. until year 2003., was really hot in Latvia. The average temperature was 35.3 degrees."

 

In this updated sentence, the decimal character in the number "25.3" has been preserved, while the dot after the years "2000." and "2003." remains unchanged, you no longer need to put the word (gads) after the year number.

If my solution helped you, you can click on mark as best response.

Kindest regards

Leon Pavesic


@daniils21 For Find, use

FIND: ([0-9]{1;3}).

That will find from 1 to 3 numbers, but not 4 numbers, followed by a dot, but not 4 numbers.

 

@Doug_Robbins_Word_MVP 

Hi!

thanks for reply though your suggested expression replaces dots only in hyperlinks, but actual numbers remain with the dot 

 

Hi, Leon!
unfortunately your expression is not valid:(

@daniils21 Can you upload a typical document so that I can investigate the issue.