Skip to main content
Solved

Count number of unique characters into a string

  • February 12, 2016
  • 4 replies
  • 193 views

philippeb
Enthusiast
Forum|alt.badge.img+18

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!

Best answer by takashi

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

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

4 replies

davideagle
Contributor
Forum|alt.badge.img+21
  • Contributor
  • February 12, 2016

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


takashi
Influencer
  • Best Answer
  • February 13, 2016

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


takashi
Influencer
  • February 13, 2016
takashi wrote:

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),[^-]+,"")) 

philippeb
Enthusiast
Forum|alt.badge.img+18
  • Author
  • Enthusiast
  • February 15, 2016
takashi wrote:

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

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

OK great this is exactly what I need.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings