How do i calculate the total occurrence number of a symbol in a string?

I an trying to make a widget blueprint where i need to display nucleotide sequence and a number of occurrence of each nucleotide (that is symbol, A, C, G, T) and the total nucleotide (symbol) number. I tried to use ForEachLoop node to check each array element to count the occurrence number of each nucleotide, but it always returns 1. For the total number of nucleotides i tried to get the length of the array, but it also returns 1. I assume that array functions in text/string attribute to the whole word but not the single character. If it is so, then are there any symbol functions to use in blueprints? If i am wrong then what am i doing wrong? How can i implement this task?

I’ve come across a few comments by different people who said comparing text-based variables using == is a bad practice and you should not do that, I don’t know exactly why, maybe experienced programmers could clear that out.


As for your issue, you can transform the input to string and use the Find In String function. But keep in mind that this function returns the first or the last index (if you search from the end), so I guess you can find the first target letter, increment your counter, remove that letter from the string, start a new search, and so on until the string contains no more target letters.

Great! If you could convert your comment into an answer and mark the question as Resolved, that would be superb.

Thanks for the answer. Did you mean Find Substring function? I think it is not suitable for this. I found the solution. I used Get Character Array from String function instead of Make Array and it did what i wanted.