• Login
Community
  • Login

Replace random values with 0

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 290 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.
  • R
    Raoul Emil
    last edited by Raoul Emil Sep 13, 2023, 1:22 AM Sep 13, 2023, 1:20 AM

    Hello. I want to search for this (in Notepad++)
    

    env_factor : { x , y , z }

         Where x,y,z are random values/numbers
         And replace with this
    

    env_factor : { 0 , 0 , 0 }

         An example
    

    env_factor : { 0.5215321 , 0.11243 , 0.94 } to replace with
    env_factor : { 0 , 0 , 0 }

         Thank you.
    
    C 1 Reply Last reply Sep 13, 2023, 1:49 AM Reply Quote 0
    • C
      Coises @Raoul Emil
      last edited by Coises Sep 13, 2023, 1:50 AM Sep 13, 2023, 1:49 AM

      @Raoul-Emil

      From the main menu, select Search | Replace… and fill in:

      Find what: env_factor\s*:\s*\{\s*\d+(\.\d*)?\s*,\s*\d+(\.\d*)?\s*,\s*\d+(\.\d*)?\s*\}

      Replace with: env_factor : { 0 , 0 , 0 }

      Be sure the radio button Regular expression is selected and use the Replace All button.

      This does not take into account numbers that might have minus signs or that might begin with a decimal point, without the leading zero. If you have numbers like that, replace the parts in the search like this:

      \d+(\.\d*)?

      with:

      -?(\d+(\.\d*)?|\.\d+)

      to get:

      env_factor\s*:\s*\{\s*-?(\d+(\.\d*)?|\.\d+)\s*,\s*-?(\d+(\.\d*)?|\.\d+)\s*,\s*-?(\d+(\.\d*)?|\.\d+)\s*\}

      R 1 Reply Last reply Sep 13, 2023, 1:50 AM Reply Quote 4
      • R
        Raoul Emil @Coises
        last edited by Sep 13, 2023, 1:50 AM

        @ Coises You are amazing,thank you very much.

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