Hello!
There is a string $string = aaa!bbbb!ccccc!ddddd!eeeeee!ffffff!gggg!...и до бесконечности
I need to create a regular expression that changes an arbitrary exclamation point to X
The number of characters can be at least one million repetitions of exclamation marks. Therefore, such options are:
preg_replace('/^[^!]+/i', 'X', $string); //меняем первый по счету preg_replace('/^([^!]+)(!)([^!])/i', 'X', $string); //меняем второй по счету preg_replace('/^([^!]+)(!)([^!])(!)([^!])/i', 'X', $string); //меняем третий по счету...
...unsuitable
Tell me how to make such a pattern (regular expression per sample), so that by changing one digit, choose which one ! change. Roughly speaking: I put it somewhere 1, the first one changed, I put 2, the second one changed, etc.
Thank!