Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 在sql数据库上使用awk更改所有iframe“;宽度“;及;高度“;尺寸_Mysql_Wordpress_Awk - Fatal编程技术网

Mysql 在sql数据库上使用awk更改所有iframe“;宽度“;及;高度“;尺寸

Mysql 在sql数据库上使用awk更改所有iframe“;宽度“;及;高度“;尺寸,mysql,wordpress,awk,Mysql,Wordpress,Awk,我有一个WordPress数据库,里面有成千上万的帖子。我需要一些正则表达式和awk命令的帮助来遍历数据库(在我转储数据库之后),并将所有大小更改为统一的大小,如width=“600”height=“350” 现在看起来是这样的: Some paragraph text here, like a description [tab:Short Code Here] <iframe width="200" height="180" src="https://www.youtube.com/em

我有一个WordPress数据库,里面有成千上万的帖子。我需要一些正则表达式和awk命令的帮助来遍历数据库(在我转储数据库之后),并将所有大小更改为统一的大小,如
width=“600”height=“350”

现在看起来是这样的:

Some paragraph text here, like a description
[tab:Short Code Here]
<iframe width="200" height="180" src="https://www.youtube.com/embed/aD4grQXZPfg" frameborder="0" allowfullscreen></iframe>
[tab:Different Short Code Here]
<IFRAME SRC="http://other-videohost.com/embed-ksq9vn3gwc16.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=250 HEIGHT=300></IFRAME>
Some paragraph text here, like a description
[tab:Short Code Here]
<iframe width="600" height="350" src="https://www.youtube.com/embed/aD4grQXZPfg" frameborder="0" allowfullscreen></iframe>
[tab:Different Short Code Here]
<IFRAME SRC="http://other-videohost.com/embed-ksq9vn3gwc16.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=600 HEIGHT=350></IFRAME>
这里有一些段落文本,比如描述
[选项卡:此处为短代码]
[选项卡:此处有不同的短代码]
数据库中的结果应如下所示:

Some paragraph text here, like a description
[tab:Short Code Here]
<iframe width="200" height="180" src="https://www.youtube.com/embed/aD4grQXZPfg" frameborder="0" allowfullscreen></iframe>
[tab:Different Short Code Here]
<IFRAME SRC="http://other-videohost.com/embed-ksq9vn3gwc16.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=250 HEIGHT=300></IFRAME>
Some paragraph text here, like a description
[tab:Short Code Here]
<iframe width="600" height="350" src="https://www.youtube.com/embed/aD4grQXZPfg" frameborder="0" allowfullscreen></iframe>
[tab:Different Short Code Here]
<IFRAME SRC="http://other-videohost.com/embed-ksq9vn3gwc16.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=600 HEIGHT=350></IFRAME>
这里有一些段落文本,比如描述
[选项卡:此处为短代码]
[选项卡:此处有不同的短代码]
因此,一些附加信息:

我将使用mysqldump转储数据库,然后希望使用regex运行一个成功的命令来更改我的目标模式,而不会影响图像或其他非iframe的元素。 可以将所有iFrame作为目标,因为iFrame仅在站点上用于视频嵌入

服务器在ubuntu 14.04上运行WordPress

请注意,在某些情况下,宽度和高度位于src后面,而在其他情况下则位于src前面,如我的示例中所示。此外,我们希望使其不区分大小写


欢迎提出建议和解决办法。感谢大家的帮助。

使用GNU awk进行
gensub()
和单词边界(
\这是一种非常不可靠的方法。您需要一个脚本(例如,在PHP中)这将从数据库中获取记录并进行更新。@RuslanOsmanov感谢您的评论。欢迎您提出任何建议。我要求使用服务器搜索并像awk一样进行替换,因为我对php的经验更少。请为我指出正确的方向。欢迎使用其他解决方案。谢谢这又是一个很棒的正则表达式代码。它在第一次使用时就完美无瑕。我的第二个问题你已经回答了,我想让你知道我真的很感激它!真的是一个专业人士!