Jump to content
UBot Underground

How to find the indexes or positions of a character which occurs multiple times?


Recommended Posts

I've made a bot which should insert a string of text into a block of text. I want it to insert the text after a random fullstop '.'

 

So far I've got this:

 

set(#blocktext - text from file

 

 

set(#blocktext, $insert text(#blocktext, ". {#stringtoinsert}", $find index(#blocktext, ".")), "Global")

 

This inserts my string after the FIRST fullstop in every block text..

 

However I want to randomize this and make it choose a random full stop to insert the string after.

 

After some hours of working on it I think a solution could be to return the indexes of all the full stops and then instruct ubot to choose a random position from these numbers to insert the string after..

 

Any ideas?

Link to post
Share on other sites

Join the conversation

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

Guest
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.

Loading...
×
×
  • Create New...