0

Hello I'm trying to do negative matching on regex in PHP and I can't get it to work. You can test out the regex below on Rubular online.

\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)

<a href="https://www.youtube.com/watch?v=yy7pc2YdrPg">frame</a>

https://www.youtube.com/watch?v=yy7pc2YdrPg

What I would like to happen is the first line in the quote not be matched, and the second line in the quote be matched. I would like to search for a " character at the end of the youtube URL being matched, to check if the URL is an HTML tag's attribute's value, or is just a piece of text on its own (eg. inside a <p> tag as copy). I know how to regex search for if the match ends with " (by adding ["] at the end) but I want to regex search for if the match does not end with a "

How can I do this?

I have searched Google and Stack Overflow for the answer and I could not get anything to work.

desbest
  • 4,746
  • 11
  • 51
  • 84

0 Answers0