Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 找到一个图案并在新行上用相同的图案替换它_Regex_Notepad++ - Fatal编程技术网

Regex 找到一个图案并在新行上用相同的图案替换它

Regex 找到一个图案并在新行上用相同的图案替换它,regex,notepad++,Regex,Notepad++,请注意: Array ( [0] => Tiger [first_name] => Tiger [1] => Nixon [last_name] => Nixon [2] => Accountant [position] => Accountant [3] => Tokyo [office] => Tokyo [4] => 2016-11-08 [start_date] => 2016-11-08 [5] => 320800 [s

请注意:

Array ( [0] => Tiger [first_name] => Tiger [1] => Nixon [last_name] => Nixon [2] => Accountant [position] => Accountant [3] => Tokyo [office] => Tokyo [4] => 2016-11-08 [start_date] => 2016-11-08 [5] => 320800 [salary] => 320800 ) Array ( [0] => Garrett [first_name] => Garrett [1] => Winters [last_name] => Winters [2] => Accountant2 [position] => Accountant2 [3] => Tokyo [office] => Tokyo [4] => 2016-11-08 [start_date] => 2016-11-08 [5] => 170750 [salary] => 170750 ) Array ( [0] => Ashton [first_name] => Ashton [1] => Cox [last_name] => Cox [2] => Accountant3 [position] => Accountant3 [3] => Tokyo [office] => Tokyo [4] => 2016-11-08 [start_date] => 2016-11-08 [5] => 86000 [salary] => 86000 ) Array ( [0] => Cedric [first_name] => Cedric [1] => Kelly [last_name] => Kelly [2] => Accountant4 [position] => Accountant4 [3] => Tokyo [office] => Tokyo [4] => 2016-11-08 [start_date] => 2016-11-08 [5] => 433060 [salary] => 433060 ) 
希望它看起来像这样:

Array ( 
[0] => Tiger [first_name] => Tiger 
[1] => Nixon [last_name] => Nixon 
[2] => Accountant [position] => Accountant 
[3] => Tokyo [office] => 
...
在记事本++usng正则表达式中找到以下内容:
\[(\d)\]

然后换成这个
\n\[$1\]


\[(\d)\]
-这将查找此模式
[0]
[1]

(\d)
-这捕获方括号内的值:
0
1


\n\[$1\]
-这将在打开的方括号前放置一行新行,
$1
是在上面的查找中的括号
()
中捕获并在此处替换的内容,然后以
]
方括号结束


注意注意方括号中的
\
转义,例如
\[

另一个答案加上:

Find What: " Array"
Replace With: "\nArray"

也可以使每个数组都位于新行。

在捕获中包含方括号会更简单。因此,搜索
(\[\d\])
,并替换为
\n\1
。tks,对于我的参考。
\n$1
\n\1
相同