Community
    • Login

    Need help with finding and replacing

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 339 Views 2 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.
    • Chec PufosC Offline
      Chec Pufos
      last edited by PeterJones

      Hello, i have 30 notepad files in which i want to change a number at certain lines.

      This is the lines that are found in each document:

      
      Size {
              #  [range: 1 ~ 256000, default: 1000]
              I:max=1000
      
              #  [range: 1 ~ 256000, default: 500]
              I:min=500
      

      I want to change the number after i:max and i:min in each document, but be aware that there are other places where these 2 appear and i need to change the numbers only in these specific lines. How can i do that? Also, the number after ''default: ‘’ it is different in each document in both lines.

      -–

      moderator added code markdown around text; please don’t forget to use the </> button to mark example text as “code” so that characters don’t get changed by the forum

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP Offline
        PeterJones @Chec Pufos
        last edited by PeterJones

        @Chec-Pufos ,

        Your specs are more vague than you think they are.

        Assuming you want to replace any positive integer immediately after that specific I:max= with 987 and any positive integer immediately after that specific I:min= with 654, then it could be done with something like:
        FIND = (?-is)(Size\s+{\s*.*\R\s*I:max=)\d+(\s*.*\R\s*I:min=)\d+
        REPLACE = ${1}987${2}654
        SEARCH MODE = Regular Expression
        REPLACE IN FILES

        hopefully, you can figure out what to change in order to replace with values other than 987 or 654

        highly recommended: always back up your data before trying a regex that someone hands you; always try a new regex on a single file and make sure it behaves as you expect before trying on the full 30 files.

        -—

        Useful References

        • Please Read Before Posting
        • Template for Search/Replace Questions
        • Formatting Forum Posts
        • Notepad++ Online User Manual: Searching/Regex
        • FAQ: Where to find other regular expressions (regex) documentation
        1 Reply Last reply Reply Quote 0

        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