In the tradition of best practice & code improvement, a third iteration of a script that finds the Nth occurrence of a Target string within another string (Original author unknown, V2 author vextant).
This version returns zero if an Nth occurrence is not found (similar to V1), but also provides the ability to search the string Right to Left so that you can find the last occurrence, 2nd to last occurrence, etc.
The code has also been simplified.
(It's international Talk Like a Pirate Day today)
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.