3
I need help on something very specific, which involves good interpretation, is the following, I need to inform a word on regex example nt the last letter that would be t was extended to the first sequence of t's and stop, for example...
in
$txt = "nttttouterttt";
echo preg_replace('/nt/', '', $txt);
saida: tttouterttt
expected result
$txt = "nttttouterttt";
echo preg_replace('/nt/', '', $txt);
saida: outerttt
if the next letter does not outside’t', does not continue the sequence
$txt = "ntptttouterttt";
echo preg_replace('/nt/', '', $txt);
saida: ptttouterttt
nt is removed but would like to remove the nt>ttt< entire, remaining only outerttt, case the string outside ntptttouterttt it would withdraw only nt, is it possible? there would be another method? I accept suggestions and material...
please give some examples of input and their respective outputs so that we can analyze their logic in action, it is easier to deliver something correct ;)
– Paz
@Paz, really, I’ve already edited.
– Felipe Duarte
In the first case, instead of
nt, tried to use then[t]+? Orn[t]*? Where you use the Quantifier+, which will match between one and unlimited times the operator t or*which corresponds from zero to unlimited times.– danieltakeshi
Serious guy that this? I tested here and it seems to me that it worked, I thought it would be bigger complication kk, thank you very much vei...
– Felipe Duarte
@danieltakeshi posted as answer to Felipe accept, so if other people have the same question and arrive here via research can see easier.
– Paz