Forum Discussion

daniils21's avatar
daniils21
Copper Contributor
Jul 02, 2023

using wildcards in word

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 

 

  • LeonPavesic's avatar
    LeonPavesic
    Silver Contributor

    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's avatar
      daniils21
      Copper Contributor
      Hi, Leon!
      unfortunately your expression is not valid:(

Resources