Sorry for basic question. How I can replace some pattern with the exact number of characters? Let's say I have a string AAAABBBBCCCC and variables that keep start and end positions of B (characters defined here with B in real world could be any, I just know only position of pattern I want to replace not pattern itself). And I want to replace this pattern with the same number (known for me) of X characters. So I use