Hello Max,
So, from you example, below, I suppose that you would like to change the value 625 of the tag size, for an other one, whatever the contents of the two previous lines are ?
officers = { culture = pashtun #This doesnt matter, they vary. religion = sunni #This doesnt matter either, they vary. size = 625 #I want to change this. }Well, I think that a good search/replacement, using regular expressions, could be :
SEARCH (?s-i)^officers.+?size = \K\d+
REPLACE <some digits> ( The new value of the tag size )
So :
Open your file, in Notepad++
Open the Replace dialog ( Ctrl + H )
Fill the Find what field with the above regex
Fill the Replace with field with a new integer value, for the tag size
Uncheck, preferably, the Wrap around option
Click, EXCLUSIVELY, on the Replace All button ( DON’T use the Replace button, for a step by step replacement. Indeed, nothing is changed, in that case ! )
Et voilà !
If you’re a newby, about regular expressions concept and syntax, begin with that article, in N++ Wiki :
http://docs.notepad-plus-plus.org/index.php/Regular_Expressions
In addition, you’ll find good documentation, about the new Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v1.48.0 ), used by Notepad++, since its 6.0 version, at the TWO addresses below :
http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html
http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html
The FIRST link explains the syntax, of regular expressions, in the SEARCH part
The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part
You may, also, look for valuable informations, on the sites, below :
http://www.regular-expressions.info
http://perldoc.perl.org/perlre.html
If you’re, already, fairly acquainted with regexes, here are, below, some notes about this specific regex :
The first part (?s-i), of the **search regex, are two modifiers :
The first one, (?s), forces the dot special character to represent any single character ( a standard character or an EOL character )
The second one, (?-i), forces the regex engine to do this search/replacement, in a sensitive case way
The part ^officiers, looks, for beginning of the line, ^, for the string officiers, in that exact case
Then, the part .+?size = , tries to match the shortest, non-null, range of any character, till the string size =, with a space character, after the equal sign ( Why the shortest ? Because it must be located inside the officiers {......} block ! )
Now, the \K form, forces the regex engine to forget everything that was previously matched and resets the caret location to the position between the space character, after the equal sign, and the first digit of the size value
Finally, the part \d+ matches all the digits of the size’s value
In replacement, just type the new value of the size tag, which will replace the old value
But, I guess that you showed your example, split, in several lines, in order to tell us, about the right zone to be changed ! So your text would rather be written, as below :
officers = { culture = pashtun religion = sunni size = 625 }In that case, the search regex should be, simply re-written, as below :
(?-si)^officers.+size = \K\d+
This time, the part .+ represents the longest range of standard characters only, of the current line ( due to the (?-s) modifier ), till the string size =, with a space character after the equal signBest Regards,
guy038