JSFiddle - React, Tailwind, and code Playground

HTML

<ul>
  <li>
    foo
    <iframe class="videoObject" src=""></iframe>
  </li>
  <li>
    bar
    <iframe class="videoObject" src=""></iframe>
  </li>
  <li>
    foo https://www.youtube.com/watch?v=Vr3ya_uPmxg
    <iframe class="videoObject" src=""></iframe>
  </li>
</ul>

JavaScript

$('li').each(function() {
  var url = $(this).text();
  if (url != undefined || url != '') {
    var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=|\?v=)([^#\&\?]*).*/;
    var match = url.match(regExp);
    if (match && match[2].length == 11) {
      // Do anything for being valid
      // if need to change the url to embed url then use below line           
      $(this).find('.videoObject').attr('src', 'https://www.youtube.com/embed/' + match[2] + '?autoplay=0&enablejsapi=1').show();
    } else {
      // Do anything for not being valid
    }
  }
});