DW finds a regular expression for all characters before a string

Time:2020-11-23

When I write HTML with DW editor, I like to write comments, such as comments on <! — header >, and so on. When a large change is made, I need to search and replace in batch. In order to operate in batch, I write a regular expression to process it.

Find:

Copy codeThe code is as follows:
(\r\n|\n|.)*?<\!– header –>

The effect is as follows:

点击查看原图

Another common use is the character between strings
For example, find the characters between <! — header start > to <! — header end >, including line breaks.
Find:

Copy codeThe code is as follows:
<\!– header start –>(\r\n|\n|.)*?<\!– header end –>

As shown in the picture:

点击查看原图

DW regular interpretation, for DW regularity, there is no pattern modifier like PHP, such as / I, / s
Therefore, the metacharacter (.) of DW does not match the newline character, so (| n |) *? Can only be used to replace the modifier of / s.

In DW, line breaks in windows and UNIX are line breaks, plus any characters. You can match multiple lines.