i have 8 sentences, i would to copy in my files after an html tag in random one of these 8 sentences
is it possible with notepad? how?
Terry R last edited by
If you thinking of using a regular expression (regex) then no. regex does NOT have a calculating ability and no random number generator with which to do an assessment and then pick 1 of 8 sentences.
However Notepad++ also provides the environment to support some programming languages, such as Pythonscript. Of course this then reduces the support field considerably.
However there might be a way that regex could ‘emulate’ some randomness. It would depend on what occurs within the html tag. For example if we would select a particular character (say 8th inside the tag), knowing it could be anything within the alphabet it could be possible to select a ‘random’ sentence based on that character’s value. So with 8 sentences you would create 8 lists of characters. Whether they be [a-d], [e-h], [i-l] type or [a,f,u], [b,e,z] types where the characters are random, then this could help in the selection process.
If you need the 8 sentences to be used only once then the above idea fails.
cipher-1024 last edited by cipher-1024
I don’t think NPP has a random number generator. It’s possible you could figure out something with a regex and use the line number or number of characters to get some faux randomness, but that’s beyond my regexpertice. I would use a scripting plugin like Python or Lua to accomplish this.
EDIT: Terry snuck a better answer in before me!
thanks for your answer, i shall see with python
Scott Sumner last edited by
So as a Pythonscript example, this will grab and display a random line from the current file when run:
from random import randint notepad.messageBox(editor.getLine(randint(1, editor.getLineCount()) - 1).rstrip(), 'A random line from active file...')
Note that I’m kinda assuming that the OP’s sentences will be one-per-line in a file…