Need help changing a number section in these text files for a game
-
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.
-
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
-
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 - Find What :
-
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
-
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 group1
, 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
-
-
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