That is horribly confusing. No wonder you are having a hard time. OK, let's go.
First off, let's stop using those {space}. I would prefer to use your original underline. _yadda
So that:
abc{return}
{space}abc{return}
{space}abc{space}{return}
{space}a{space}b{space}c{space}{return}
c{space}a{return}
we will make as:
abc
_abc
_abc_
_a_b_c_
c_
OK? Forget about the Returns for now.
Let's now look at your examples.
Example texts:
---------------------------------------
1. a_b_c
Nothing happens. This is correct, no search string applies.
2. _abc__ (two spaces following)
Result: _abc__
3. _a_b_
_abc
Result: _abc
4. abc__abc_aabc_abcc
Result: abc__abc_aabc_abcc
5. abbcc_c_a_b_c_
Result: abbcc_c_a_b_c_
All of the results are 100% correct. The results are precisely what you have told Word to do.
So...what is your problem???
Take #5 as a test. The result is: abbcc_c_a_b_c_, and that is, again, 100% correct.
What you have not told us, is what do you want it to be? Because it IS doing it correctly.
I think you may have a misunderstanding of how searching works. It takes your search string, and does its work. It then takes the next string, and does its thing.
It has NO memory of what it did previously. If YOU want it to, you can, but YOU have to tell it to do that.
So, with abbcc_c_a_b_c_, yes the search string _a_b_c_ will turn it into: abbcc_c_a_b_c_
THEN, the search string c_ turns it into:
abbcc_c_a_b_c_
Which is EXACTLY what it is supposed to do.
Your results are, again, 100% correct. There is absolutely nothing wrong with the results. If the results are not what YOU want, then....tell Word to do it differently.
How? I don't know, as you are not telling ME.
With the example: abbcc_c_a_b_c_ you seem to be implying that the result abbcc_c_a_b_c_ is not correct.
OK, I will not dispute that, but WHAT is not correct?
WHICH rule should not be applied? Here is your list again, and I will use your numbering.
1. abc
2. _abc
3. _abc_
4. _a_b_c_
5. c_
Now....are you saying if 4 applies (found and actioned) ....do NOT use #5?
Do not use it all?
Do not use it on words that #4 has been actioned on?
Use it on words that #4 has been actioned on...but undo the #4 action?
Look at the above questions. Is there anything about code? No, there is not. It is purely logic. And for the nth time...THAT is your problem.
You do not state what is wrong with example #5 (abbcc_c_a_b_c_). Whether you like it or not, it IS correct. Your search list was searched, and actioned correctly.
Perhaps if you actually REALLY stated the logic, we may help you move on. So...
1. tell me what the result of abbcc_c_a_b_c_ SHOULD be;
2. tell what are the conditions/rules that will make it the result it SHOULD be
Because, as it stands, it searched used #4, applied the action, searched using #5 and applied the action.
Word does not remember that #4 was used (and actioned) when it goes on to using #5.
If YOUR logic requires that it do so...while not trivial to implement, Word most certainly can be made to do that. All it needs is to have..........the logic. YOU have to tell Word...wait second, #4 was actioned here, so skip doing #5 (if that is indeed what you want...I have no idea as you have not stated anything).