Community
    • Login

    Find and replace subset of string

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 924 Views
    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
      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
        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
          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
            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
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors