Por ejemplo,
txt="1ab34cab4abba";
t0="ab";
x=3;//"ab"appears three times in TXT——??X=N Rows(Loc(txt,t0));
m1=2;// The first occurrence of "ab" in TXT is 2
m2=7;// The second occurrence of "ab" in TXT is 7
m3=10;// The third occurrence of "ab" in TXT is 10
Cómo usa cna las estadísticas JSL?
¡Gracias!
Aquí hay una pieza de JSL que hace su cálculo y crea una lista JMP con los resultados
names default to here(1);
txt="1ab34cab4abba";
t0="ab";
resultList = {0};
target = txt;
while(contains(target,t0),
resultList[1] = resultList[1] + 1;
insert into(resultList,contains(target,t0));
target=substr(target,1,contains(target,t0)-1) || "~~" || substr(target,contains(target,t0)+2);
);
show(resultList);
Vuelve
resultList = {3, 2, 7, 10};Buscar una cadena para todas las apariciones de un patrón muestra una solución de propósito general utilizando el comparador de patrones. Más difícil de entender, pero debería tener un comportamiento O (N) en cadenas grandes.
txt="1ab34cab4abba";
t0="ab";
num=3