Community
    • Login

    Find and replace subset of string

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 1.2k 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.
    • Douglas McAlpineD Offline
      Douglas McAlpine
      last edited by

      Hi there,

      I have a large file in which I want to replace any strings in my file where Buchwert has a decimal place and replace it with 0

      So this is ok
      bestand=“-6718” buchwert=“0” wrtmndrng_kmlrt=“0”

      But this is a problem
      bestand=“6719” buchwert=“0.831392131958484” wrtmndrng_kmlrt=“0”

      How do I do it without deleting anything past the second "?

      1 Reply Last reply Reply Quote 1
      • Douglas McAlpineD Offline
        Douglas McAlpine
        last edited by Douglas McAlpine

        In the end I got this working with:

        Find what:
        "buchwert="0.[0-9]+" "

        Replace:
        buchwert=“0”

        1 Reply Last reply Reply Quote 1
        • gerdb42G Offline
          gerdb42
          last edited by

          Search for Regular Expression: buchwert="0\.\d+"
          Replace with: buchwert="0"

          If you need to replace any number with decimals search for buchwert="\d+\.\d+"

          1 Reply Last reply Reply Quote 1
          • gerdb42G Offline
            gerdb42
            last edited by

            Ok, I see you found it by yourself. Note that \d is equivalent to [0-9]. But you need to escape the "." to "\." or else it will match any character e.g. “0n234” would also match.

            1 Reply Last reply Reply Quote 2

            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