Bernd
12/23/2019 (Mon) 23:26:08
No.33366
del
>>33337>I spent some time trying to make the python work without regexI don't recommend this. Replacement of multiple overlapping patterns is tedious task. For example, taking Berndese string "bk^k" and replacing it into English: first we replace "bk^k" with "q", but next we'll match "q" (it also exists in Berndese) and replace it into "a". So, translation is ruined. No sorting or other method would help.
To overcome this, you need to keep track of replaced substrings (start/end indexes), but it isn't fun too, because replacements have different length than matching pattern. So, in the end you'll need to create finite automation like in regex (DFA/NFA). It isn't impossible, but worth only in educational purposes and not an easy task at all.
Also here is updated version with better table for replacements and some small fixes.