正则表达式需要一些词而不接受一个词
Regex to require some words and not accept a word
<iframe.+?((width="320")).+?(?!height=".+")src="https?:\/\/www.youtube.com\/embed\/([a-zA-Z0-9_-]{11})"[^>]+?><\/iframe>
我需要匹配宽度为“320”但没有高度的 youtube iframe。即使我输入高度,它仍然 returns 正确。
请指导我。
使用锚定的负面展望开始:
(?!.*height="[^"]+")iframe.+?width="320".+?src="https?://www.youtube.com/embed/([\w-]{11})"[^>]+?></iframe>
<iframe.+?((width="320")).+?(?!height=".+")src="https?:\/\/www.youtube.com\/embed\/([a-zA-Z0-9_-]{11})"[^>]+?><\/iframe>
我需要匹配宽度为“320”但没有高度的 youtube iframe。即使我输入高度,它仍然 returns 正确。 请指导我。
使用锚定的负面展望开始:
(?!.*height="[^"]+")iframe.+?width="320".+?src="https?://www.youtube.com/embed/([\w-]{11})"[^>]+?></iframe>