*Help* How to change multiple unknown text string with just one?

  • Hello everybody!
    I hope you are all alright and healthy.

    So, I’ve searched for this on Google and on this Forum and haven’t been able to find it. Either that, or the solutions I found didn’t work for me (probably because I’m just too dumb).

    So, I have a big XML file in which I have multiple strings with a constant text, followed by different strings.
    I’d like to keep that constant text and change all of the different options that follow, with another new constant text.

    For example -
    Example 1: <property name=“Name” type=“string” value=“Iso”/>
    Example 2: <property name=“Name” type=“string” value=“Bin”/>
    Example 3: <property name=“Name” type=“string” value=“Wire”/>
    Example 4: <property name=“Name” type=“string” value=“Whatever”/>

    And I’d like to change the Iso, Bin, Wire and Whatever for: HELLO.
    Obviously, all of those lines are in different places of the file, and there are many more. I just simplified the task at hand for the sake of simplicity.

    I hope you can help a newbie out.

    Thank you all in advance.

  • Hello, @chuny_ok and All,

    No problem, with regular expressions ! So :

    • Open the Replace dialog ( Ctrl + H )

    • SEARCH (?-s)<property name="Name" type="string" value="\K.+(?="/>)



    • SEARCH (?-s)(<property name="Name" type="string" value=").+

    • REPLACE \1HELLO"/>

    • Tick, preferably, the Wrap around option

    • Select the Regular expression search mode

    • Click on the Replace All button ( Do not use the step by step Replace button, with the first S/R ! )

    If OK, I could develop how these regexes work, next time ;-))

    Best Regards,


  • or for custom replace another idea is

    find what:Iso|Bin|Wire|Whatever
    replace with:HELLO
    Select the Regular expression mode

  • Hi, @chuny_ok, @gurikbal-singh and All,

    Of course, your S/R, @gurikbal-singh, is more simple and obvious but could grasp too many occurrences, as it does not care about the tags and the attributes involved, with the same value :-((

    But I admit, that in case of few found occurrences, the use of the step by step replacement, with the Replace button, after verification, may be enough for @chuny_ok !

    Best Regards


  • Thank you @guy038 and @gurikbal-singh
    I tried with your suggestions and all of them worked.
    Much appreciated!
    Thanks again!

  • @guy038 Hello my friend, I have another one for you!
    Now, I’m not sure if this is possible at all but, let’s try.

    I have several blocks within an XML file
    They are a little something like this

    <property name=“Evaluator” type=“int” value=“4”/>
    <property name=“zoomValue” type=“float” value=“0.8”/>
    <property name=“Framingn” type=“int” value=“2”/>
    <property name=“Name” type=“string” value=“High”/>
    <property name=“PropertyName” type=“string” value=“Whatever”/>

    Like I said, there are many blocks like that in different places of the same XML but with different values, different properties, etc.
    But they are all within the <Instance> </Instance> tags.

    I’d like to replace all of them, not matter the content inside those tags with only one <Instance> </Instance> of my own.
    Obviously, doing that one by one would take about two hours since there are probably between 70 and 100 I’d need to change. So is there any way to do what I’m after?.

    Thank you very much in advance.

  • Hi @Chuny_OK

    -Try this:

    Open the Replace dialog (Ctrl + H) and type in:

    Search: (?s)(<Instance>).*?(</Instance>)
    Replace: $1HELLO$2

    Replace "HELLO" with your string.
    Check the Wrap around option
    Select the Regular expression search mode
    Click on the Replace All button

  • @astrosofista said in *Help* How to change multiple unknown text string with just one?:


    Thank you! It worked like a charm!
    Thank you for your quick reply too!

  • @Chuny_OK

    You’re welcome. If you want to get involved in regex, let me suggest you to take a look at this page:


    Have fun!

  • Instead of starting a new thread I searched and found this one which appears to address my problem.

    I have several files that contain this line, price: 12000 where the number varies in every file… I tried with the (*) filter to change that to price: 1000 in all of the files at once but the program wouldn’t cooperate. I’m not a coder so some of the above examples are confusing to me. Can someone suggest what to enter in the replace with: line?
    Thanks. ;)

  • Hi @george-fisher and All,

    Easy with regular expressions !

    • Open the Find in Files dialog ( Ctrl + Shift + F )

    • SEARCH (?-i)price:\x20\d+

    • REPLACE price:\x201000

    • Fill in the Filters: and Directory: fields, as desired

    • Select the Regular expression search mode

    • Click on the Replace in Files button

    • Click on the OK button of the confirmation dialog

    Voila ;-))

    Notes :

    • First, the (?-i) ensures that the search process is performed in a non-insensitive way

    • Then, the part price: looks for this literal string, with this exact case

    • Now, \x20 is the hexadecimal syntax of a space character

    • Finally the \d+ syntax represents any non-null consecutive range of digits, so any decimal number

    Best Regards,


  • Hello again!

    I need some more help.
    I have several lines within an XML file that have something like this:

    <property name=“dateTimeHour” type=“uint32” container=“StaticArray” arraySize=“1”>

    In which only the numerical value that’s within the <value>X</value> is different in each line along different parts of the same XML File.
    I would like to change all those different values with the same one, just one.

    Could any of you kind human beings help me?.

    Thank you!

  • Hi @Chuny_OK

    -Try the following:

    Open the Replace dialog (Ctrl + H) and type in:

    Search: (?-s)(?<=<value>)(\d)+(?=</value>)
    Replace: 000

    Replace 000 with your replacing number.
    Check the Wrap around option
    Select the Regular expression search mode
    Click on the Replace All button

    Have fun!

  • @astrosofista

    Thank you!
    Although, there are many other strings with
    <value>X</value> but with different properties.

    <property name=“dateTimeHour” type=“uint32” container=“StaticArray” arraySize=“1”>
    <property name=“dateTimeMinute” type=“uint32” container=“StaticArray” arraySize=“1”>
    <property name=“overrideAtmosphere” type=“bool” container=“StaticArray” arraySize=“1”>

    I only need to change those with DateTimeHour.
    If I do what you suggested, every number in-between the <value> </value> tags will get changed!

  • @Chuny_OK said in *Help* How to change multiple unknown text string with just one?:

    I only need to change those with DateTimeHour

    How about using the following regex in place of the current one:

    So it finds the line with dateTimeHour, then progresses to the NEXT line, finds the number and what ever you type into the Replace field is what is inserted.

    As this uses the \K regex command you must use the “Replace All” button. So if you need to cyle through the changes one at a time using the singular “Replace” button please come back with that request and another regex could be made to suit.


  • @Terry-R

    That worked like a charm, Terry!
    Thanks a lot!

  • @Terry-R

    Hello Terry
    Unfortunately, after further analysis, somehow when I use that expression, the file gets messed up after some of those lines I mentioned above.

    What I was doing is, replacing all those different dateTimeHour values, with the number 17.

    In one particular line, (it’s like after the 8th modification), I get this:

    <property name=“dateTimeHour” type=“uint32” container=“StaticArray” arraySize=“1”>

    And then the file ends.

    But originally, the file continued with several other strings.
    In the original file, that line was like this:

    <property name=“dateTimeHour” type=“uint32” container=“StaticArray” arraySize=“1”>

    And, like I said, there were plenty other lines after that. The document was huge.
    But after using your command, I get what I described above and then the file ends.

    I tried placing it with other values, like 0. But no matter which value I enter, that value gets duplicated
    For example>
    <property name=“dateTimeHour” type=“uint32” container=“StaticArray” arraySize=“1”>

    …And then, the file ends.

    Very strange.

  • @Chuny_OK said in *Help* How to change multiple unknown text string with just one?:

    And then the file ends.

    I presume you mean the file gets truncated? In large files with some types of look-aheads there can be instances of this occuring, but I wouldn’t have thought this in your case.
    Try this alternative regex.
    Find What:(?-s)(.+?dateTimeHour.+\R<value>)\d+
    Replace With:\1xx

    Where xx is the number you wish to use, it can be any length i.e. 1, 3765 etc. In this case as we are capturing the previous line and a bit of the current line (so we only get the datetimehour values you want to change) we need to write it back, hence the \1 in front of the number you want to insert.


  • @Terry-R
    Hello Terry
    Doesn’t quite work.

    If I do that, the whole document gets replaced by the number I entered :(

    The strange thing is that when I first started this thread, the help I was getting was always working! And the files are still XML, the structure is quite similar, although the properties are different. So I don’t get why neither the first tips I was provided nor the new ones are working.

  • @Chuny_OK

    For instance, there’s another thing I’d like to change:

    <property name=“gameMinExposure” type=“float” container=“StaticArray” arraySize=“1”>

    This line appear multiple times along this large document, but with different values along the way.
    If I wanted to replace al those different values with just one (like -10 for example), I can’t do that.

Log in to reply