Skip to main content

Hi,

I have this string for example : "Hello-World! Let's talk-about-you!"

If I want to know the number of "-" (here would be 3) into that string, how could I do that with a transformer?

Thanks!

I'm sure there are a few options, but I would use a StringSearcher and put the matches into a list, then expose the list and count the elements. Like this:

countstringinstances.fmw


Also FME String Functions might be an option in this case.


Also FME String Functions might be an option in this case.

0684Q00000ArLIzQAN.png

A more direct expression flashed. Remove every character except hyphens, and then get the length.

@StringLength(@ReplaceRegEx(@Value(str),e^-]+,"")) 

A more direct expression flashed. Remove every character except hyphens, and then get the length.

@StringLength(@ReplaceRegEx(@Value(str),x^-]+,"")) 

OK great this is exactly what I need.


Reply