If anyone who is better at regex could assist it would be greatly appreciated. I am trying to get the following regex (see URL) to find all HTML JavaScript comments within the script tag. This will run using Windows PowerShell for the task needed.
The below example is what I have so far. However, it still doesn't:
(?s)(?(?=\A).*?<script[^>]*>).*?(?:\K\/\/|<\/script>.*?(?:<script[^>]*>|\z)(*SKIP)(*FAIL))
- should highlight all the text to the right of the "//" until line-break
- should not include URLs inside of the script tag
- should not be case sensitive for the script tag
Example URL also including seven test scenarios: https://regex101.com/r/YpCJXM/1
Goal: If each of the scenarios could have the comment text highlighted while not including any of the extra areas outside of the script tag. As long as it works on regex101 I can make it work with PS!
Edit: I am fully aware you should not parse this with regex! However, I'm sure someone more skilled in regex could easily handle just completing the few scenarios needed for this task.
Edit_2: The below is another example. However, it still doesn't:
(\/\*[\s\S]*?\*\/|([^:]|^)\/\/.*)
- should only include text inside the script tag
Answer: The below is a slight change of MikeM's answer to allow both http or https
(?si)(?<!http:|https:)\/\/[^\r\n]*(?=(?:(?!<script[^>]*>).)*<\/script>)