找到一个模式并在新行

时间:2016-11-16 01:57:32

标签: 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 [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 regex

2 个答案:

答案 0 :(得分:0)

找到这个: \[(\d)\]
并替换为此 \n\[$1\]

\[(\d)\] - 这会找到此模式[0][1] ...
(\d) - 这会捕获方括号内的值:01 ...

\n\[$1\] - 这会在空方括号之前添加一个新行,$1是在上面的查找中括号()中捕获的内容并在此处替换,然后以]方括号。

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

答案 1 :(得分:0)

另一个答案加上:

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

还要将每个数组放在新行上。