如何使用 notepad++ 正则表达式更改 asciidoc 代码块样式?

How can I change asciidoc code block style by using notepad++ regular expressions?

我正在尝试更改 HTML asciidoc 代码块之类的。我想使用记事本++正则表达式转换特定的代码块样式。 每个代码块都以新行开头

默认格式

....
>>> def echo(value=None):
 print("Execution starts when 'next()' is called for the first time.")
 try:
     while True:
         try:
             value = (yield value)
         except Exception as e:
....

所需形式:

[source,python]
----
    >>> def echo(value=None):
     print("Execution starts when 'next()' is called for the first time.")
     try:
         while True:
             try:
                 value = (yield value)
             except Exception as e:
---- 

我按顺序使用了以下正则表达式,但它们不起作用。

1。 来自 :\r\n.... 收件人:\r\n[source,python]\r\n----

2。 来自 :.... 收件人:----

不要忘记 . 是正则表达式中的特殊字符。要匹配文字 . 你需要转义它 \..

您可以使用以下表达式。确保正则表达式匹配换行符匹配大小写环绕 选项已启用。

找什么:

(\.\.\.\.)\s(.*?)(\.\.\.)

替换为:

[source,python]\n--------

替换后:

[source,python]
----
>>> def echo(value=None):
 print("Execution starts when 'next()' is called for the first time.")
 try:
     while True:
         try:
             value = (yield value)
         except Exception as e:
----