• Login
Community
  • Login

Need help changing a number section in these text files for a game

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 4 Posters 1.4k 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.
  • B
    Bobby Atkins
    last edited by Aug 17, 2018, 5:39 PM

    I have a text file that I am trying to change in notepad++ from “moveLimit”:6 to “moveLimit”:120, I tried the replace method, but all I got was this “moveLimit”:1206 instead and I have like thousands of these little files, they are for the game’s levels.

    1 Reply Last reply Reply Quote 1
    • T
      Terry R
      last edited by Aug 17, 2018, 9:19 PM

      Did you want to post your regular expression (regex) so we can see where you may have the problem. You can see in most posts that the regex is in red with a shadow background. This is done by typing a ‘grave accent’ character before and after the regex, so like regex. That character is on the same key as a tilde (~) on a qwerty keyboard. That prevents the interpreter window you type in from potentially altering what you type.

      Terry

      1 Reply Last reply Reply Quote 1
      • P
        PeterJones
        last edited by PeterJones Aug 17, 2018, 9:32 PM Aug 17, 2018, 9:31 PM

        If the problem is literally that, you don’t even need to use a regular expression:

        • Find What : “moveLimit”:6
        • Replace With : “moveLimit”:120
        • Search Mode ☑ Normal

        Note, here I used smart quotes, like in @Bobby-Atkins 's post… I have a feeling, given it’s a game config file, that they’re really standard quotes, so it would really be:

        • Find What : "moveLimit":6
        • Replace With : "moveLimit":120
        • Search Mode ☑ Normal

        There are ways to do it with a fancier regular expression, but unless the change is more complicated than has been described, there’s no reason for the complication.

        Hopefully, if this isn’t sufficient, Bobby will give us more details, with the regular expression in the grave accents (aka “back ticks”: `expression` ). For more formatting help, see this post

        1 Reply Last reply Reply Quote 2
        • T
          Terry R
          last edited by Aug 17, 2018, 10:17 PM

          Actually @PeterJones , they are ALL regexs are they not? Even using ‘normal’ characters in the search window constitutes a regex, even if the mode is normal, not regular expression mode.

          The O’Reilly book Mastering Regular Expressions (?) refers to all patterns typed in this way as regexs. Some are just more complicated than others.

          Terry

          1 Reply Last reply Reply Quote 2
          • G
            guy038
            last edited by guy038 Aug 17, 2018, 11:31 PM Aug 17, 2018, 11:11 PM

            Hi, @terry-r and All,

            I do understand your general idea. But, for instance, Terry, how would you class the following search :

            This (simple) test

            • Is it the literal sentence This (simple) test, with the adjective simple, between parentheses, in order to emphasize its meaning ?

            • Is it a regex, matching the expression This simple test with the word simple stored as group 1, for future use, either in search and/or replacement ?

            And, more important, what Jeffrey E. F. Friedl, the author of the Mastering Regular Expressions book, would think about it ?

            My God ! We are, by now, involved in philosophical questions ;-))

            Cheers,

            guy038

            1 Reply Last reply Reply Quote 1
            • T
              Terry R
              last edited by Aug 17, 2018, 11:21 PM

              Great answer @guy038 ! And of course for any newbies on this forum the definition of a regex is most likely the search string used only when under the ‘extended’ or ‘regular expression’ modes of search , find and replace, using the ‘metacharacter’ options made available. Because that’s where your ‘literal’ example turns into a ‘regex’.

              When using the ‘normal’ mode or looking at a very simple string search as in this instance I probably should refrain from using the ‘regex’ word.

              Thanks for the clarification.

              Terry

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