


织梦cms如何通过正则批量查找替换数据库的自定义内容?
正则的表达式在MY SQL中也有应用,但是在具体将查找的东西直接进行Replace的时候目前还不能解决,幸好后台中有个dede利用正则,利用dede正则批量替换数据库中内容,这样我们完全减小了自己的工作量了
推荐学习:织梦cms
例如网站的一个例子
是替换一个div中的内容,摘抄实践下,关键还是自己去体会,多用下正则,还是不错的、正则相关的文章我在我的博客中也多次提到了他的多种运用途径。如果你都掌握好它的话,你的工作效率就会成倍的提高了。
下面这个正则的用途是查找数据库的中自定义的DIV层中运用,一般这种用法你在采集,或者,用word直接添加内容后会用到。
看看这个是如何去除的。
例子一,去除简单自定义内容内容
选择数据表与字段:dede_addonarticle
替换方式:选择正则表达式
主键字段:aid
被替换内容:MM[\d]*GG
选择字段:body(这表是存储文章内容的),选择单选框:正则表达式,主键字段填写"aid",被替换内容为上面的正则:
例:MM[\d]*GG
替换为:可为空,也可填写你想置换为的内容。
替换条件:如果是全部,就不填写。开始测试时,先备份了数据库,然后仅替换一篇文章,条件中填写:aid=888,如果是分类,就填写:typeid=18,这样缩小替换范围,避免出错。
填写安全确认码,替换就ok了,
例子二,去除
<div style="background-color: #fff9ee; text-align: center"><font style="font-weight: bold;">文章地址址:<br />//www.jb51.net/<br /></font> </div>
上述代码,是一个不错的style,大家可以显示下,调试效果不错。
可以利用以下正则来替换:
在dede后台,选择:核心–数据库内容替换–选择表:
选择数据表与字段:dede_addonarticle
替换方式:选择正则表达式
主键字段:aid
被替换内容:
选择字段:body(这表是存储文章内容的),选择单选框:正则表达式,主键字段填写"aid",被替换内容为上面的正则:
例:
替换为:可为空,也可填写你想置换为的内容。
替换条件:如果是全部,就不填写。
注意:开始测试时,先备份了数据库,然后仅替换一篇文章,条件中填写:aid=8880,如果是分类,就填写:typeid=18,这样缩
小替换范围,避免出错。
填写安全确认码,替换就ok了,注意这个安全确认码会有失效周期,但它自己不提示,也有这个可能,会选择替换无反应,遇见
这情况,只有刷新当前页面了。
很完整了吧!其它正则参考:http://bbs.dedecms.com/214856.html,这个当中的也不完整,也不太正确,需要对比来修改调试
,很费时间。
正则是个好技术,有着很强大的应用,花了点时间看,你的工作效果会大陪的提高!
这是我在处理文章时用到一些正则表达式,里面有你要的。在Editplus中使用。
在表:dede_addonarticle中,body字段即是文章内容。
过滤Table相关的:
正则: width=\"[0-9][0-9][0-9]\"| width=[0-9][0-9][0-9]| height=\"[0-9][0-9][0-9]\"| height=[0-9][0-9][0-9],
说明:过虑height、Width。
正则:
Regular: style=\"[^"]*\"| style=[^"]*, note: Match Style="border:"
Regular: , note: matching
regular: ]*>|||]*>|| , note: matches and
Regular: border="[0-9]"| border=[0-9], note: matching border=""
Regular: ]*>|| , note: matching
regular: id=[^ ]*| id=\"[^ ]*\" , note: matching id=""
regular: title=[0-9][^ ]*| title=\"[0-9][^ ]*\"| alt=[0-9 ][^ ]*| alt=\"[0-9][^ ]*\"| alt=[a-z][^ ]*| alt=\"[a
-z][^ ]* \", Note: Match Title or alt
Regular: ]*–>, Description: Match HTML comment
Regular: <script>]*)>(.*)</script>, Description: Match all content between <script></script>
Regular: class=[a-z][^ | ^>]*| class=\"[a-z][^ |^>]*\", description: Clean up class="", fully tested
Regular:
Regular:
]*>||
| align=left|||| > ;|]*)>|
Regular expression is a universal standard, and most computer languages support regular expressions, including as3, Here are some commonly used regular expression statements, so you don’t have to write them yourself when you use them
^[0-9]*[1-9][0-9]*$ //Matching Positive integer
^-[0-9]*[1-9][0-9]*$ //Match negative integer
^-?\d $ //Match integer
^\d (\.\d )?$ //Match non-negative floating point numbers (positive floating point numbers 0)
^(([0-9] \.[0-9] *[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9] )|([0-9]*[1 -9][0-9]*))$ //Match positive floating point numbers
^((-\d (\.\d )?)|(0 (\.0 )?))$ //Match non-positive floating point numbers (negative floating point number 0)
^(-(([0-9] \.[0-9]*[1-9][0-9]*)| ([0-9]*[1-9][0-9]*\.[0-9] )|([0-9]*[1-9][0-9]*)))$ / /Match negative floating point numbers
^(-?\d )(\.\d )?$ //Match floating point numbers
^[A-Za-z] $ //Match by A string of 26 English letters
^[A-Z] $ // Matches a string of 26 uppercase letters
^[a-z] $ // Matches a string of 26 uppercase letters A string consisting of lowercase English letters
^[A-Za-z0-9] $ //Match a string consisting of numbers and 26 English letters
^\w $ / / Matches a string consisting of numbers, 26 English letters or underscores
^[\w-] (\.[\w-] )*@[\w-] (\.[\w- ] ) $ //Match email address
^[a-zA-z] ://Match (\w (-\w )*)(\.(\w (-\w )*)) *(\?\S*)?$ //Match url
Regular expression matching Chinese characters: [\u4e00-\u9fa5]
Match double-byte characters (including Chinese characters in (within): [^\x00-\xff]
Regular expression matching blank lines:\n[\s| ]*\r
Regular expression matching HTML tags:/ .*|/
Regular expression matching leading and trailing spaces: (^\s*)|( \s*$)
Regular expression matching email addresses: \w ([- .]\w )*@\w ([-.]\w )*\.\w ([-. ]\w )*
Regular expression matching URL: ^[a-zA-z] ://(\w (-\w )*)(\.(\w (-\w) )*))*(\?\S*)?$
Is the matching account legal (starting with a letter, 5-16 bytes allowed, alphanumeric underscores allowed): ^[a-zA-Z][ a-zA-Z0-9_]{4,15}$
Matches domestic phone numbers: (\d{3}-|\d{4}-)?(\d{8}|\d {7})?
Matches Tencent QQ number: ^[1-9]*[1-9][0-9]*$
The following table shows the metacharacters and their regular expressions A complete list of behaviors in the context of an expression:
\ Marks the next character as a special character, or a literal character, or a backreference, or an octal escape character.
^ Matches the beginning of the input string. If the RegExp object's Multiline property is set, ^ also matches the position after '\n' or '\r'.
$ Matches the end position of the input string. If the Multiline property of the RegExp object is set, $ also matches the position before '\n' or '\r'.
* Matches the preceding subexpression zero or more times.
Matches the previous subexpression one or more times. Equivalent to {1,}.
? Matches the preceding subexpression zero or one time. ? Equivalent to {0,1}.
{n} n 是一个非负整数,匹配确定的n 次。
{n,} n 是一个非负整数,至少匹配n 次。
{n,m} m 和 n 均为非负整数,其中n
? 当该字符紧跟在任何一个其他限制符 (*, +, ?, {n}, {n,}, {n,m}) 后面时,匹配模式是非贪婪的。非贪婪模式尽可能少的匹
配所搜索的字符串,而默认的贪婪模式则尽可能多的匹配所搜索的字符串。
. 匹配除 "\n" 之外的任何单个字符。要匹配包括 '\n' 在内的任何字符,请使用象 '[.\n]' 的模式。
(pattern) 匹配pattern 并获取这一匹配。
(?:pattern) 匹配pattern 但不获取匹配结果,也就是说这是一个非获取匹配,不进行存储供以后使用。
(?=pattern) 正向预查,在任何匹配 pattern 的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要
获取供以后使用。
(?!pattern) 负向预查,与(?=pattern)作用相反
x|y 匹配 x 或 y。
[xyz] 字符集合。
[^xyz] 负值字符集合。
[a-z] 字符范围,匹配指定范围内的任意字符。
[^a-z] 负值字符范围,匹配任何不在指定范围内的任意字符。
\b 匹配一个单词边界,也就是指单词和空格间的位置。
\B 匹配非单词边界。
\cx 匹配由x指明的控制字符。
\d 匹配一个数字字符。等价于 [0-9]。
\D 匹配一个非数字字符。等价于 [^0-9]。
\f 匹配一个换页符。等价于 \x0c 和 \cL。
\n 匹配一个换行符。等价于 \x0a 和 \cJ。
\r 匹配一个回车符。等价于 \x0d 和 \cM。
\s 匹配任何空白字符,包括空格、制表符、换页符等等。等价于[ \f\n\r\t\v]。
\S 匹配任何非空白字符。等价于 [^ \f\n\r\t\v]。
\t 匹配一个制表符。等价于 \x09 和 \cI。
\v 匹配一个垂直制表符。等价于 \x0b 和 \cK。
\w 匹配包括下划线的任何单词字符。等价于'[A-Za-z0-9_]'。
\W 匹配任何非单词字符。等价于 '[^A-Za-z0-9_]'。
\xn 匹配 n,其中 n 为十六进制转义值。十六进制转义值必须为确定的两个数字长。
\num 匹配 num,其中num是一个正整数。对所获取的匹配的引用。
\n 标识一个八进制转义值或一个后向引用。如果 \n 之前至少 n 个获取的子表达式,则 n 为后向引用。否则,如果 n 为八进
制数字 (0-7),则 n 为一个八进制转义值。
\nm 标识一个八进制转义值或一个后向引用。如果 \nm 之前至少有is preceded by at least nm 个获取得子表达式,则 nm 为
后向引用。如果 \nm 之前至少有 n 个获取,则 n 为一个后跟文字 m 的后向引用。如果前面的条件都不满足,若 n 和 m 均为
八进制数字 (0-7),则 \nm 将匹配八进制转义值 nm。
\nml 如果 n 为八进制数字 (0-3),且 m 和 l 均为八进制数字 (0-7),则匹配八
关于批量替换 正则表达式
这是我在处理文章时用到一些正则表达式,里面有你要的。在Editplus中使用。
在表:dede_addonarticle中,body字段即是文章内容。
过滤Table相关的:
还有一些,可供你参考,我加了一些注释,发个贴太累了,哎~~~自己摸索吧:
正则: width=\"[0-9][0-9][0-9]\"| width=[0-9][0-9][0-9]| height=\"[0-9][0-9][0-9]\"| height=[0-9][0-9][0-9],说明:过虑height、Width。
------------------------------------------------------
正则:
-------------------------------------------------- ----------
Regular: style=\"[^"]*\"| style=[^"]*, note: Match Style="border:"
-------------------------------------------------- -------
Regular: , note: matches
------------------------------------ ------------------
Regular: ]*>|||< ;strong [^>]*>|| , note: matches and
--------- --------------------------------------------------
Regular: border="[0-9]"| border=[0-9], note: match border=""
----------------- -------------------------------------
Regular: ]*>|| , note: matches
------------------- ----------------------------------
Regular: id=[^ ]*| id=\"[^ ]*\", note: match id=""
-------------------------- ----------------------------
Regular: title=[0-9][^ ]*| title= \"[0-9][^ ]*\"| alt=[0-9][^ ]*| alt=\"[0-9][^ ]*\"| alt=[a-z][^ ] *| alt=\"[a-z][^ ]*\", note: match Title or alt
--------------------- --------------------------------
Regular: , Description: Match HTML comments
--------------------------------- ---------------------
Regular: <script>]*)>(.*)</script>> ;, Description: Matches all content between <script></script>
------------------------ -----------------------------
Regular: class=[a-z][^ |^>]* | class=\"[a-z][^ |^>]*\", description: Clean up class="", fully tested
-------------- ----------------------------------------
Regular: ]*)>||
-------------------------------------------------- ----------
Regular:
]*>||
| align=left|| || |]*)>|
The above is the detailed content of How does Dreamweaver CMS search and replace the custom content of the database in batches through regular expressions?. For more information, please follow other related articles on the PHP Chinese website!

织梦cms忘记密码的解决办法:1、登录MySql,找到网站对应的数据库的名称,点击进入该数据库;2、找到dede_admin表,然后找到管理员相关信息行并选中;3、通过还原的方式将密码还原为初始值,将pwd的值修改为默认的“f297a57a5a743894a0e4”即可。

织梦cms系统没有收费。织梦CMS是一款开源的内容管理系统,其核心代码是免费提供的,用户可以免费下载最新版本的织梦CMS,并且还可以获取相关的技术支持和文档。但在使用过程中,用户可能需要购买额外的功能模块或者主题模板,这些是收费的,购买这些收费的模块和模板,价格根据具体的功能和设计复杂度而定。

织梦cms安全性相对比较好,其原因有:1、漏洞修复速度快;2、CSRF(跨站点请求伪造)保护;3、XSS(跨站脚本攻击)保护;4、SQL注入保护;5、代码审计。

织梦cms是用PHP语言写的。织梦CMS(DedeCMS)是一个PHP开源网站管理系统,作用是构建中小型网站;它采用PHP+MySQL技术开发,可同时使用于windows、linux、unix平台。

织梦cms连接数据库失败解决方法:1、检查数据库配置,确保在织梦CMS的根目录下的 /data/config.php 文件中正确设置了数据库的相关信息;2、测试数据库连接,通过创建一个简单的PHP脚本来测试数据库连接是否成功;3、检查数据库服务器状态,在织梦CMS的根目录下的 /data/config.php 文件中更换数据库服务器地址;4、检查网络连接。

织梦cms数据库名称的修改方法:1、直接修改mysql里的数据库名称;2、打开根目录下的“data”文件夹,然后找到“common.inc.php”文件;3、修改其中“$cfg_dbname”后面的数据即可。

织梦cms主要是做网站的建设、管理和维护。1、网站建设,织梦CMS提供了丰富的模板和插件资源,用户可以根据自己的需求选择合适的模板和插件,快速搭建自己的网站;2、网站管理,织梦CMS提供了简单易用的管理后台界面,用户可以通过浏览器登录后台进行网站管理;3、网站维护,织梦CMS提供了自动备份和数据库管理等功能,保证网站的安全和稳定运行。

织梦cms备案号位置的更改方法:1、进入织梦后台,然后找到“模板”分类;2、点击“默认模板管理”;3、找到“footer.htm”,并点击修改;4、找到“{dede:global.cfg_powerby/}”,然后填写备案号即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver Mac version
Visual web development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
