如何交换两个 if 和 then 语句
How to swap two if and then statements
我有一些代码需要修改(1000 行),我想从这里开始
if $one=0 and $two=32 then $dist=1
if $one=0 and $two=15 then $dist=2
if $one=0 and $two=19 then $dist=3
对此
if $one=0 and $dist=1 then $two=32
if $one=0 and $dist=2 then $two=15
if $one=0 and $dist=3 then $two=19
简而言之,将 $two 及其值与 $dist 及其值交换。
记事本+的正则表达式可以吗?
我试过了:
if ([^ ]+) and ([^]+) then ([^]+)
- Ctrl+H
- 查找内容:
($two=\d+)( then )($dist=\d+)
- 替换为:
</code> </li>
<li><kbd>全部替换</kbd></li>
</ul>
<p><strong>解释:</strong></p>
<pre><code>($two=\d+) : group 1, contains "$two=1 or more digits"
(\s+then\s+) : group 2, literally "then" surrounded by spaces
($dist=\d+) : group 3, contains "$dist=1 or more digits"
$
必须转义,因为它是正则表达式中的特殊字符。
替换:
: group 3 group 2 group 1
给定示例的结果:
if $one=0 and $dist=1 then $two=32
if $one=0 and $dist=2 then $two=15
if $one=0 and $dist=3 then $two=19
我有一些代码需要修改(1000 行),我想从这里开始
if $one=0 and $two=32 then $dist=1
if $one=0 and $two=15 then $dist=2
if $one=0 and $two=19 then $dist=3
对此
if $one=0 and $dist=1 then $two=32
if $one=0 and $dist=2 then $two=15
if $one=0 and $dist=3 then $two=19
简而言之,将 $two 及其值与 $dist 及其值交换。
记事本+的正则表达式可以吗?
我试过了:
if ([^ ]+) and ([^]+) then ([^]+)
- Ctrl+H
- 查找内容:
($two=\d+)( then )($dist=\d+)
- 替换为:
</code> </li> <li><kbd>全部替换</kbd></li> </ul> <p><strong>解释:</strong></p> <pre><code>($two=\d+) : group 1, contains "$two=1 or more digits" (\s+then\s+) : group 2, literally "then" surrounded by spaces ($dist=\d+) : group 3, contains "$dist=1 or more digits"
$
必须转义,因为它是正则表达式中的特殊字符。替换:
: group 3 group 2 group 1
给定示例的结果:
if $one=0 and $dist=1 then $two=32 if $one=0 and $dist=2 then $two=15 if $one=0 and $dist=3 then $two=19