I have a string that looks like this:
<script> some random script, maybe even some line breaks\ </script>
or even
<script type="random/type" src="https://even_a_source.com"> random scripts </script>
I would like to insert a class tag in the script part, like this:
<script class="addMe" type="random/type" src="https://even_a_source.com"> random scripts </script>
without changing the rest of the script tag.
I figured using regex would be a good start: /<[^>]*>/ matches <script> and </script> I think but I didn't progress further unfortunately.
As mentioned in the comments, using the gem nokogiri might be easier to deal with this, I'm trying it right now and update this if I find the solution.