Find character position/index from a string

Hi, I’m pretty new to bubble…I need to achieve something which I feel is very basic but been stuck on it for a while.

I’m trying to achieve something like get the position of char “f”, from a string “hjjjsjjksishnfsjksksnsj” which should return a number

Hi there, @kanibaba1… I’m all but certain the correct answer involves regex, but regex confuses the heck out of me for some reason, so I like to try to do these types of things with Bubble operators.

This suggestion is probably pretty hacky, but it does work, so I didn’t think it could hurt to throw it out there for you until someone comes along with a solution that uses regex. Let’s say the string in your example is in an element called Input A, and you have a text element where you want to display the position of character f. The following expression in the text element produces the desired result of 14…

Input A's value:split by (f):number of characters:first item + 1

Note that I entered “f” for the character to split by, but that character could be dynamic based on another input or something.

Anyway, like I said, that’s probably pretty hacky, but it can’t hurt as food for thought, eh?

Best…
Mike

1 Like

Thanks a lot @mikeloc …this gave me an dea to resolve the issue for my use case.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.