In this post, we will see how to resolve Regex to Match Two Strings Including Anything in Between Without Line-Breaks
Question:
I want to replace all the .png extensions in my HTML to .webp so I am doing the regex expressing to match the png links:but after it’s minified, it’s no longer working, and it matches the start string until the last occurrence of the second string with everything in between, so the following:
Best Answer:
Try with/S
non-whitespace character matcher instead of .
matches to any:\.\/assets\/images\/\S*\.png
regex101 Demo
If you have better answer, please add a comment about this, thank you!
Source: Stackoverflow.com
Leave a Review