I am experiencing what seems to be a strange behaviour with StringReplace while trying to add an extra pattern to an existing list of patterns.
The problem is to translate a string into Morse code, for which I assume here for simplicity is defined by rules contained in the list "translationPatterns".
I cannot understand why the following three cases give such results (in the example I show, The letters "e" and "t" translate into "." and "-" respectively, to keep it simple):
StringReplace["eeeeee ttt ee",
Join[translationPatterns, {___ ~~ "ttt" ~~ ___ :> "abc"} ]]
"......abc" (I cannot understand why what's on the left of "ttt" is not replaced as well...)
StringReplace["eeeeee ttt ee",
Join[translationPatterns, {__ ~~ "ttt" ~~ _ :> "abc"} ]]
"......abc.." (This is equally strange, though coherent with the previous result.)
StringReplace["eeeeee ttt ee",
Join[{___ ~~ "ttt" ~~ ___ :> "abc"}, translationPatterns]
"abc" (This is what I would expect in the first case.)
Why the first case does not provide the same result as the last one?