Replace different values with one value



  • I have done a quick google search but I am still struggling to find what I am looking for.

    I am editing the XML file for a game(this is freemode so it is just for fun) where the driving skills of the characters are displayed as below.

    <drivingSkill>0.8754684168</drivingSkill>
    <drivingSkill>0.6954855478</drivingSkill>
    <drivingSkill>0.5321546751</drivingSkill>

    How can I search and replace so that, in one movement, they all change to the below?

    <drivingSkill>1</drivingSkill>
    <drivingSkill>1</drivingSkill>
    <drivingSkill>1</drivingSkill>

    I will add that they are not together as above, but spread throughout the XML document.

    Many thanks in advance.



  • Hello, @Covertraptor90,

    Very easy, Indeed !

    • Move to the very beginning of your file ( Ctrl + Origin )

    • Open the Replace dialog ( Ctrl + H )

    • Paste or type the following regex search <drivingSkill>\d\.\d+</drivingSkill>, in the Find what: zone

    • Paste or type the following replacement text <drivingSkill>1</drivingSkill>, in the Replace with: zone

    • Select the Regular expression search mode

    • Click on the Replace All button

    Et voilà !

    Notes :

    • The syntax \d matches any single digit, from 0 to 9

    • The escaped dot \. stands for the decimal dot character. It must be escaped because dot is, normally, a special regex character !

    • The syntax \d+, identical to \d{1,}, matches any non empty range of consecutive digits

    • Everything else is just text, which matches itself, in, both, search and replacement !

    Best Regards,

    guy038


Log in to reply