最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】dreamweaver中的正则表达式替换

dreamweaver regex crifan 2617浏览 0评论

【背景】

某人要在dreamweaver中需要实现,将:

html contain 1 want to replace with 3

中的1,替换为3。

其原先的写法是:

    查找: ([hre])1

    替换:$13

刚开始我以为写错了,后来发现,貌似本身没错,但是dreamweaver无法正确识别:

会把$13识别成,第13个group的值,而不是$1加上字符’3′

 

【解决过程】

1.虽然已经知道了正则的一般写法,但是还是想要,搞清楚,dreamweaver本身的语法,然后再写正则。

2.结果倒是搜了半天,竟然没有找到,dreamweaver官网的,关于其中所用的正则的写法。

最后找了个,相关的教程:

Using regular expressions – Part 2: Finding and replacing text

里面说到了:

Deleting duplicate words

To eliminate the duplicate, you need to replace both words with just the first one. Within the regex, you use \1 as a backreference to the first capturing group. In a replace operation, the same value is represented by $1.

但是到此,还是没法解决问题。

3.后来参考了,同样是adobe其下的,另外一款软件的正则的解释:

Home / Developing ColdFusion 9 Applications / The CFML Programming Language / Using Regular Expressions in Functions -> Regular expression syntax

其中有:

\\x

A hexadecimal representation of character, where d is a hexadecimal digit

\ddd

An octal representation of a character, where d is an octal digit, in the form \000 to \377

所以,上述例子的正则,可以试着改为:

查找:([hre])1
替换:$1\063

或者:

查找:([hre])1
替换:$1\\33

(如果不工作,则换为这个试试:

查找:([hre])1
替换:$1\33

其中:

字符’3’=八进制的063=十六进制的33==十进制的51

 

【总结】

dreamweaver的文档,看来做的还是不够。

因为正常情况下,至少应该找到:

dreamweaver的在线官网文档,关于如何使用自身软件,其中应该包括对应的正则语法才对。

转载请注明:在路上 » 【整理】dreamweaver中的正则表达式替换

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.166 seconds, using 22.16MB memory