Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Dream-weaving cms uses regular batch search to replace database custom content

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Dream cms through regular batch search to replace the database custom content method? This problem may be often seen in our daily study or work. I hope you can gain a lot from this question. The following is the reference content that the editor brings to you, let's take a look at it!

How does Dream Weaving cms replace the custom content of the database through regular batch search?

Regular expressions are also used in MY SQL, but it can not be solved when we directly Replace what we are looking for. fortunately, there is a dede in the background that uses regularities and uses dede regularities to replace the contents in the database in batches, so we have completely reduced our workload.

Recommended study: dream weaving cms

For example, an example of a website

Is to replace the content of a div, excerpt practice, the key is to experience, use more regular, or good, regular-related articles I have repeatedly mentioned in my blog a variety of ways to use it. If you master it well, your work efficiency will be doubled.

The purpose of the following rule is to find the custom DIV layer in the database, which is usually used when you are collecting, or after adding content directly with word.

See how this is removed.

Example 1, remove simple custom content

Select data tables and fields: dede_addonarticle

Replacement: select regular expression

Primary key field: aid

Content to be replaced: MM [\ d] * GG

Select field: body (this table stores the content of the article), select the checkbox: regular expression, fill in "aid" in the primary key field, and replace the content with the regular above:

Example: MM [\ d] * GG

To be replaced by: blank or fill in the content you want to replace.

Replacement condition: if it is all, do not fill in. At the beginning of the test, first back up the database, and then replace only one article, fill in: aid=888, if it is a category, fill in: typeid=18, so as to narrow the scope of replacement and avoid errors.

Fill in the security confirmation code and replace it with ok.

Example 2, remove * content

Article address: / / www.jb51.net/

The above code, is a good style, you can show that the debugging effect is good.

You can replace it with the following rules:

(. *)

In the dede background, select: core-Database content replacement-Select Table:

Select data tables and fields: dede_addonarticle

Replacement: select regular expression

Primary key field: aid

Content to be replaced: (. *)

Select field: body (this table stores the content of the article), select the checkbox: regular expression, fill in "aid" in the primary key field, and replace the content with the regular above:

Example: (. *)

To be replaced by: blank or fill in the content you want to replace.

Replacement condition: if it is all, do not fill in.

Note: at the beginning of the test, back up the database first, and then replace only one article. Fill in: aid=8880. If it is a category, fill in: typeid=18, so shrink.

Small replacement range to avoid errors.

Fill in the security confirmation code and replace it with ok. Note that this security confirmation code will have a failure period, but it does not prompt itself, and it is also possible that it will choose to replace without response.

In this case, you have to refresh the current page.

It's complete! Other regular references: http://bbs.dedecms.com/214856.html, which is incomplete and incorrect, requires comparison to modify and debug

Oh, it takes a long time.

Regular is a good technology, has a very powerful application, spend some time to see, your work effect will be greatly improved!

Here are some regular expressions I use when dealing with articles, which have what you want. Used in Editplus.

In table: dede_addonarticle, the body field is the content of the article.

Filter Table related:

] *) > |

Regular: width=\ "[0-9] [0-9] [0-9]\" | width= [0-9] [0-9] [0-9] | height=\ "[0-9] [0-9] [0-9] [0-9] [0-9]

Note: worry too much about height, Width.

Regular: |] * > | | Note: match or.

Regular: style=\ "[^"] *\ "| style= [^"] *. Note: match Style= "border:"

Regular:] *) > (. *), note: match

Regular:] * > |] * > | |, Note: match and

Regular: border= "[0-9]" | border= [0-9]. Note: match border= ""

Regular:] * > | |, Note: match

Regular: id= [^] * | id=\ "[^] *\". Note: match id= ""

Regular: title= [0-9] [^] * | title=\ "[0-9] [^] *\" | alt= [0-9] [^] * | alt=\ "[0-9] [^] *\" | alt= [Amurz] [^] * | alt=\ "[a

-z] [^] *\ ", note: match Title or alt

Regular:] *->, description: match HTML comments

Regular:] *) > (. *), description: all the contents between matches

Regular: class= [a murz] [^ | ^ >] * | class=\ "[a murz] [^ | ^ >] *\", description: clean up class= "", has been fully tested

Regular:] *) > |

Regular:] * > | align=left |] *) > |

Regular expressions are a general standard. Most computer languages support regular expressions, including as3. Here, we extract some common regular expression statements so that you don't have to write them yourself when you use them.

^ [0-9] * [1-9] [0-9] * $/ / match positive integers

^-[0-9] * [1-9] [0-9] * $/ / match negative integers

^ -?\ During $/ / matching integers

^\ d + (\.\ d +)? $/ / matches 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] *)) $/ / matches positive floating point numbers

^ (-\ d+ (\.\ d+)?) | (0 + (\ .0 +)?)) $/ / matches non-positive floating point numbers (negative floating point + 0)

^ (- ([0-9] +. [0-9] * [1-9] [0-9] *) | ([0-9] * [1-9] [0-9] *. [0-9] +) | ([0-9] * [1-9] [0-9] *)) $/ / matches negative floating point numbers

^ (-?\ d +) (\.\ d +)? $/ / match floating point numbers

^ [A-Za-z] + $/ / matches a string of 26 English letters

^ [Amurz] + $/ / matches a string of 26 English letters in uppercase

^ [amurz] + $/ / matches a string of 26 lowercase letters

^ [A-Za-z0-9] + $/ / matches a string of numbers and 26 letters

^\ w match $/ / match a string consisting of numbers, 26 letters, or underscores

^ [\ w -] + (\ .[\ w -] +) * @ [\ w -] + (\ .[\ w -] +) + $/ / matches the email address

^ [a-zA-z] +: / / match (\ w + (-\ w+) *) (\. (\ w + (-\ w+) *)) * (\?\ S*)? $/ / match url

Regular expressions that match Chinese characters: [\ u4e00 -\ u9fa5]

Match double-byte characters (including Chinese characters): [^\ X00 -\ xff]

Regular expression that matches blank lines:\ n [\ s |] *\ r

Regular expression that matches the HTML tag: /. * | /

Regular expression that matches leading and trailing spaces: (^\ s*) | (\ sblank $)

The regular expression that matches the Email address:\ W + ([- +.]\ w +) * @\ w + ([-.]\ w +) *.\ w + ([-.]\ w +) *

Regular expression that matches the URL URL: ^ [a-zA-z] +: / / (\ w+ (-\ w+) *) (\. (\ w+ (-\ w+) *)) * (\?\ S*)? $

Whether the matching account is legal (5-16 bytes are allowed at the beginning of the letter, and alphanumeric underscores are allowed): ^ [a-zA-Z] [a-zA-Z0-9 _] {4j 15} $

Match domestic phone number: (\ d {3}-|\ d {4} -)? (\ d {8} |\ d {7})?

Match Tencent QQ number: ^ [1-9] * [1-9] [0-9] * $

The following table is a complete list of metacharacters and their behavior in the context of regular expressions:

\ Mark the next character as a special character, or a literal character, or a backward reference, or an octal escape character.

^ matches the starting position of the input string. If the Multiline property of the RegExp object is set, ^ also matches the position after'\ n'or'\ r'.

$matches the end of the input string. If the Multiline property of the RegExp object is set, $also matches the position before'\ n'or'\ r'.

* matches the previous subexpression zero or more times.

+ matches the previous subexpression one or more times. + is equivalent to {1,}.

? Matches the previous subexpression zero or once. ? It is equivalent to {0jue 1}.

{n} n is a non-negative integer that matches a determined n times.

{n,} n is a non-negative integer that matches at least n times.

{n ·m} m} m and n are non-negative integers, where n |

There are some for your reference. I added some notes. I am too tired to post a post. Hey, feel for yourself:

Regular: 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], indicating that you worry too much about height and Width.

Regular: |] * > | | Note: match or.

Regular: style=\ "[^"] *\ "| style= [^"] *. Note: match Style= "border:"

Regular:] *) > (. *), note: match

Regular:] * > |] * > | |, Note: match and

Regular: border= "[0-9]" | border= [0-9]. Note: match border= ""

Regular:] * > | |, Note: match

Regular: id= [^] * | id=\ "[^] *\". Note: match id= ""

Regular: title= [0-9] [^] * | title=\ "[0-9] [^] *\" | alt= [0-9] [^] * | alt=\ "[0-9] [^] *\" | alt= [Amurz] [^] * | alt=\ "[Amurz] [^] *\". Note: match Title or alt.

Regular:, description: match HTML comments

Regular:] *) > (. *), description: all the contents between matches

Regular: class= [a murz] [^ | ^ >] * | class=\ "[a murz] [^ | ^ >] *\", description: clean up class= "", has been fully tested

Regular:] *) > |

Regular:] * > | align=left |] *) > |

Thank you for reading! After reading the above, do you have a general understanding of Dream Weaving cms's method of regular batch search and replacement of database custom content? I hope the content of the article will be helpful to all of you. If you want to know more about the relevant articles, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report