Community
    • Login

    Replace 0 with 0.000

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    replace allreplace zeroweather data
    3 Posts 2 Posters 686 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.
    • Lakhwinder SinghL
      Lakhwinder Singh
      last edited by

      I have weather data to use for simulation. In that data, I want to replace only 0 in a single line to 0.000 such as

      0
      0.221
      1.021
      0
      0
      0.223
      to
      0.000
      0.221
      1.021
      0.000
      0.000
      0.223
      I tried several ways but it select 0.221 also, but I no need to select this. only need to select 0 in a single line without a decimal.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Lakhwinder Singh
        last edited by

        @Lakhwinder-Singh ,

        Under the assumption that you literally mean just 0 => 0.000, and nothing else; and under the assumption that the numbers always start at the beginning of the line, like you showed in your example data:

        • FIND = ^0(?!\.)
        • REPLACE = 0.000
        • Search Mode = regular expression

        The ^ means “beginning of line”. The 0 is a literal character. And (?!\.) says “only if the next character is NOT a literal decimal point”.

        If the assumptions I made are not accurate, this will likely not work for you. If you have other conditions, or example data that is matching when it shouldn’t, or isn’t matching when it should, then you need to supply that data. Please read and understand the recommendations below.

        ----

        Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual Markdown syntax. To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

        1 Reply Last reply Reply Quote 3
        • Lakhwinder SinghL
          Lakhwinder Singh
          last edited by Lakhwinder Singh

          @PeterJones Thanks, it worked and solved my issue.
          It really saved my time.

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors