Community
    • Login

    Replace different values with one value

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 6.4k Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CovertRaptor90C Offline
      CovertRaptor90
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • guy038G Online
        guy038
        last edited by guy038

        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

        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors