I need to run a script that will rewrite the folder path of a html file, there will be many matches, and the replacement string needs to be computed, something like
"Html string".gsub( /images/([a-zA-Z0-9\-]+)/, "/images/#{replacement_method($1)}/" )
only problem is gsub, at least to my knowledge, will only run the replacement_method() once, and I need it to run every time since the desired replacement string changes occurring to the folder string.
Is there a way to make this work with gsub? something like the replace function in wordpress?
Any other realistic approaches?
You have to use a block:
The block will be called for each match in the string.