Jump to content

how to count an event


Recommended Posts

I have some bits of string ,it has a substring occurring many time in that string .I want to store that substring into an array and want to count its number of occurrences in that string.

I am using Match pattern function palette and while loop ,for loop still not able to implement the same

Please help me out.

Link to comment

post-7534-125871832611_thumb.png

You were correct to use a loop, but a For Loop isn't correct unless you know exactly how many times the substring exists in the main string.  I used a While Loop with the 'offset past match' to detect when to stop (it'll be -1 if the search string isn't found).  I'm not sure what you mean about storing "that substring into an array", but you can wire the 'match substring' of the Search function to an indexing tunnel and you'll get an array of the substring with as many elements as there are occurrences.

Link to comment

post-7534-125871832611_thumb.png

You were correct to use a loop, but a For Loop isn't correct unless you know exactly how many times the substring exists in the main string. I used a While Loop with the 'offset past match' to detect when to stop (it'll be -1 if the search string isn't found). I'm not sure what you mean about storing "that substring into an array", but you can wire the 'match substring' of the Search function to an indexing tunnel and you'll get an array of the substring with as many elements as there are occurrences.

thanks sir

it is working.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.