捕获后跟数字:替换语法? (织梦者)
当您处理正则表达式捕获时,当捕获后面有数字时,事情可能会变得棘手。在 PCRE 中,我可以写入
${1}000
替换第 1 组的捕获,后跟三个零。
有谁知道 Dreamweaver 替换操作中的等效语法(如果有)?
如果我们有一系列“A”而不是零,我们可以使用:
$1AAAA
但这些:
$10000
${1}0000
不起作用。
我相信正则表达式风格是 ECMAScript。只是找不到信息。 这可能不会在语法中得到解决。如果是这样,那就很高兴知道。
谢谢你!
编辑:我应该补充一点,这不是生死攸关的问题,因为我手边有许多 grep 工具。我只是想知道。
When you address a regex capture, things can get tricky when digits follow the capture. In PCRE, I can write
${1}000
to substitute the capture of Group 1 followed by three zeroes.
Does anyone know the equivalent syntax in Dreamweaver replace operations, if any?
If we had a series of "A"s instead of zeroes, we could use:
$1AAAA
But these:
$10000
${1}0000
do not work.
I believe the regex flavor is ECMAScript. Just cannot find the information.
This may not be addressed in the syntax. If so, that would be good to know.
Thank you!
Edit: I should add that this is not matter of life and death as I have a number of grep tools at my fingertips. I would just like to know.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Dreamweaver 的正则表达式查找和替换应该基于 JavaScript 的 RegExp 实现。您应该可以在替换文本中使用 $1000。但是,正如您所发现的那样,当替换文本紧随分组标记后面有数字时,无法正确识别替换组($ + 组号)。
FWIW:我已在 http://adobe.ly/DWwish 记录了一个错误
Dreamweaver's regular expression find and replace is supposed to be based on JavaScript's implementation of RegExp. You should be able to just use $1000 in the replacement text. However, like you've found, the replacement groups ($ + group number) are not properly recognized when the replacement text has digits immediately after the grouping token.
FWIW: I've logged a bug on this at http://adobe.ly/DWwish