Comment puis-je faire un indexOf () dans le langage de formule Lotus Notes (commandes @)?

StackOverflow https://stackoverflow.com/questions/184009

Question

Je ne le trouve nulle part dans l'aide de Domino Designer. Cela semble si simple!

Il me suffit de trouver la position d'un caractère dans une chaîne.

Était-ce utile?

La solution

(édité) Veuillez consulter la réponse de charles ross à la place. https://stackoverflow.com/a/19437044/11293

Ma méthode la moins efficace est la suivante.

Si vous avez vraiment besoin de la position du personnage, vous pouvez le faire:

REM {
    S  Source string
    F  Character to find
    R  Location of character in string or 0
};

S := "My string";
F := "t";
LEN_S := @Length(S);
R := 0;

@For(I := 1; I < LEN_S; I := I + 1;
    @If(@Middle(S; I; 1) = F;
        @Do(R := I; I := LEN_S);
        @Nothing
    )
);

Autres conseils

Vous pouvez utiliser @Left ou @Leftback. Je pense que dans ce cas, ils fonctionnent de la même manière.

src:= {your field value to search};
char:= {your target character};
indexof:= @Length(@Left(src;char))

searchResult: = @ Left (SearchString; "C"); indexOf: = @ If (searchResult = "; 0; @Length (searchResult)); indexOf

@Length (src) - @Length (@ReplaceSubstring (src; srch; "" "))

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top