Problem:^.+
matches only the first line of the source code in dreamweaver. I need it to match each line so that I can wrap each full line in P tags. I have 500 files to do this in.
问题:^。+仅匹配Dreamweaver中源代码的第一行。我需要它来匹配每一行,以便我可以在P标签中包装每个完整的行。我有500个文件来执行此操作。
I know ^
should match the beginning of a line and I also know that multi-line mode must be enabled for it to work on each line and not just at the beginning of the file. I also know dreamweaver uses javascript source code.
我知道^应该匹配一行的开头,我也知道必须启用多行模式才能使它在每一行上工作,而不仅仅是在文件的开头。我也知道dreamweaver使用javascript源代码。
Is lack of multi-line mode the problem? Is there any way to turn it on in dreamweaver? I tried using /m at the beginning search to enable multi-line mode, but that didn't work either.
缺少多线模式的问题?有没有办法在Dreamweaver中打开它?我尝试在开始搜索时使用/ m来启用多行模式,但这也不起作用。
I'm open to any solution for my current problem, even if it involves a different program. However, a fix for dreamweaver is ideal, 2nd place is a way to do this in notepad++, 3rd place is a way do to this in python or something (I only know javascript, you'll have to spell it out exactly in another language).
我对当前问题的解决方案持开放态度,即使它涉及不同的程序。然而,对于Dreamweaver的修复是理想的,第二个地方是在记事本++中执行此操作的方法,第三个地方是在python或其他方式做到这一点(我只知道javascript,你必须用另一种语言拼写出来)。
Thank you,
robert
谢谢,罗伯特
p.s. I found I can "select all > right click > selection > indent" to add two spaces to the beginning of each line in dreamweaver. This allows me to find the beginning of each line with / {2,}/. I really don't want to select all > indent on all 500 files, but i'm about to start since I've already spent a few hours bludgeoning dreamweaver.
附:我发现我可以“选择全部>右键单击>选择>缩进”,在Dreamweaver中每行的开头添加两个空格。这允许我用/ {2,} /找到每一行的开头。我真的不想在所有500个文件上选择所有>缩进,但我即将开始,因为我已经花了几个小时打击Dreamweaver。
4 个解决方案
#1
Don't use Dreamweaver for this - use Notepad++ (since you are familiar with it) at its regular expression support is superior.
不要使用Dreamweaver - 使用Notepad ++(因为你熟悉它),它的正则表达式支持是优越的。
If you are comfortable with a more robust scripting language (Python, Ruby, Perl, etc.) then that would be an ever better way to do it.
如果您对更强大的脚本语言(Python,Ruby,Perl等)感到满意,那么这将是一种更好的方法。
#2
The way that I might do this in DW would not involve using the find-replace tool's "Regular Expression" option, but instead using just plain old matching on a CrLf.
我在DW中执行此操作的方式不会涉及使用find-replace工具的“正则表达式”选项,而是仅使用CrLf上的普通旧匹配。
In the Find portion, since you can't directly enter a CrLf, you'll have to copy one to your clipboard beforehand and paste it in where needed.
在“查找”部分中,由于无法直接输入CrLf,因此必须事先将其复制到剪贴板并将其粘贴到需要的位置。
In the Replace portion, replace with:
在替换部分中,替换为:
</p>[CrLf]
<p>
Again, be sure to paste in a proper "[CrLf]". This will work on all but the very first and very last lines of your document, so I know this isn't a 100% solution. There are probably better solutions using other tools that someone else can recommend!
再次,一定要粘贴适当的“[CrLf]”。这将适用于文档的第一行和最后一行,因此我知道这不是100%的解决方案。使用别人可以推荐的其他工具可能有更好的解决方案!
Good luck!
-Mike
祝好运! -麦克风
#3
I had a flash of insight right after posting. (isn't that the way of it?)
发布后我发现了一些洞察力。 (不是这样的吗?)
Dreamweaver can find the end of each line with \r\n so instead of trying to work forward, i should have just worked backwards.
search: (.+)(\r\n)
replace: <p>$1</p>$2
Dreamweaver可以用\ r \ n找到每一行的结尾,所以我应该向后工作,而不是试图向前工作。搜索:(。+)(\ r \ n)替换:
$ 1 $ 2
#4
[\w\W]*
matches anything, including a newline. Its greedy, so it fact it matches everything.
[\ w \ W] *匹配任何内容,包括换行符。它贪婪,所以事实上它匹配一切。
#1
Don't use Dreamweaver for this - use Notepad++ (since you are familiar with it) at its regular expression support is superior.
不要使用Dreamweaver - 使用Notepad ++(因为你熟悉它),它的正则表达式支持是优越的。
If you are comfortable with a more robust scripting language (Python, Ruby, Perl, etc.) then that would be an ever better way to do it.
如果您对更强大的脚本语言(Python,Ruby,Perl等)感到满意,那么这将是一种更好的方法。
#2
The way that I might do this in DW would not involve using the find-replace tool's "Regular Expression" option, but instead using just plain old matching on a CrLf.
我在DW中执行此操作的方式不会涉及使用find-replace工具的“正则表达式”选项,而是仅使用CrLf上的普通旧匹配。
In the Find portion, since you can't directly enter a CrLf, you'll have to copy one to your clipboard beforehand and paste it in where needed.
在“查找”部分中,由于无法直接输入CrLf,因此必须事先将其复制到剪贴板并将其粘贴到需要的位置。
In the Replace portion, replace with:
在替换部分中,替换为:
</p>[CrLf]
<p>
Again, be sure to paste in a proper "[CrLf]". This will work on all but the very first and very last lines of your document, so I know this isn't a 100% solution. There are probably better solutions using other tools that someone else can recommend!
再次,一定要粘贴适当的“[CrLf]”。这将适用于文档的第一行和最后一行,因此我知道这不是100%的解决方案。使用别人可以推荐的其他工具可能有更好的解决方案!
Good luck!
-Mike
祝好运! -麦克风
#3
I had a flash of insight right after posting. (isn't that the way of it?)
发布后我发现了一些洞察力。 (不是这样的吗?)
Dreamweaver can find the end of each line with \r\n so instead of trying to work forward, i should have just worked backwards.
search: (.+)(\r\n)
replace: <p>$1</p>$2
Dreamweaver可以用\ r \ n找到每一行的结尾,所以我应该向后工作,而不是试图向前工作。搜索:(。+)(\ r \ n)替换:
$ 1 $ 2
#4
[\w\W]*
matches anything, including a newline. Its greedy, so it fact it matches everything.
[\ w \ W] *匹配任何内容,包括换行符。它贪婪,所以事实上它匹配一切。