Question

I can't find this anywhere in the Domino Designer help. It seems so straightforward!

All I need to do is find the position of a character in a string.

Was it helpful?

Solution

(edited) Please see the answer from charles ross instead. https://stackoverflow.com/a/19437044/11293

My less efficient method is below.


If you really need the character position though you could do this:

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
    )
);

OTHER TIPS

You could use @Left or @Leftback. I think in this case they work the same.

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;""))

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top