I have an editor where its possible to paste a video url, which I by regex convert to an embed code.
The url in the WYSIWYG-editor is:
http://emedia.is.ed.ac.uk:8080/JW/wsconfig.xml&file=mp4:directory/date_submitted/filename-stream-WSwifi.m4v
The output html is:
<p>http://emedia.is.ed.ac.uk:8080/JW/wsconfig.xml&file=mp4:directory/date_submitted/filename-stream-WSwifi.m4v</p>
To look for this I use the following regex in JavaScript:
/http:\/\/(www.)?emedia.is.ed.ac.uk:8080\/JW\/?(.*)?/
But for some reason the match contains the </p> aswell on matchgroup 2? How can I avoid that?
Try this
See it here on Regexr.
Instead of matching any character with
.*I use[^<]*, meaning match anything but “<“.I also removed the
?at the end since with the*quantifier you don’t need it, I also escaped all your dots you want to match literally.