掌上百科 - PDAWIKI

 找回密码
 免费注册

QQ登录

只需一步,快速开始

查看: 458|回复: 0

[教程] powergrep 002

[复制链接]

该用户从未签到

发表于 2017-11-18 08:52:07 | 显示全部楼层 |阅读模式
Action Part: Collect Between
* |% o0 q" ~7 G
/ J7 _, k9 u% uThe "search", "collect data", and "merge files" action types save search matches to one or more target files, at l** when "target file creation" is set to anything except "do not save results to file". If an action finds three matches 1, 2, and 3 you may want to save them as 1,2,3 into the target file rather than as 123. The "collect between" part of the Action panel is where you can tell PowerGREP what, if anything, PowerGREP should place between the collected matches. In this example we're putting a comma between all the matches.
# v9 W5 }# z2 m0 ^/ u2 `6 }! u! g5 Y/ D/ M. p- K& {3 W2 T. N
In addition or instead of putting text between matches, you can add a header and footer to each target file created by PowerGREP. When collecting matches from multiple source files (files that were searched through) into a single target file, you can also add a header and footer to the blocks of matches that were found in the same source file. You can use path placeholders to add references to the files the matches were found in.# ]& X" U' ^# W) }( V) G$ x; Z
$ w1 x+ }& `0 m+ X! Y7 J/ k4 Y: l
The appearance of the "collect between" part of the action changes based on what you select in the "between collected text" drop-down list and whether you tick "collect headers and footers". If you're not using any options that require custom text, no text box appears:
* i- |8 `: k% C  w" s! m+ T& ?# }0 ?% U
Collect line breaks between matches6 l' Z  b& S, V( x2 y
If you're using only one delimiter between the matches without any headers or footers, you get one box to type in that delimiter:8 t1 F1 t: v2 ~! a4 z( [( ]

$ k" I! z6 u' |" u7 U: `- {Collect a comma between matches" A+ z2 a6 C5 H# p# j9 L; |& G5 K0 @5 ?
If you're using multiple delimiters or headers and footers then a list with different items appears. All the items in the list are used when you execute the action. The item that you select is the one that you can edit in the text box:
  t+ @7 R9 \/ w; u" y' H- _% k3 A5 f7 [/ e. _" d/ ^. [1 X# x' y
Various headers, footers, and text between matches8 u+ i& }* B: W6 `+ B
Between Collected Text6 q6 i3 w3 M9 ]
Choose which text, if any, you want to place between text that was collected for different search matches:, g9 t' y; |2 b6 s6 G" n. I! {
2 q/ _% f. O; l/ |# u% u3 h4 n+ _' p' c- f
Nothing: Don't put anything between text collected for different matches.
) l0 [' H! _: E* ]Line break: Use a separate line to collect the text for each search match.# A; v% V0 a- v* I
Text between matches and files: Put the same text between all matches, regardless of which files they were collected from.
' o/ z% ]3 u2 {9 a2 Q$ ZText between matches only: Put text between the matches collected from the same file. Do not put any text between matches collected from different files (other than file headers and footers).4 _8 R" a1 P+ j' k, L( b5 C4 M. K, E
Text between files only: Do not put any text between matches collected from the same file. When saving text from multiple files into a single file, put text between matches collected from different files.' ?& A6 j& K6 ?7 r/ z+ w- e
Different text between matches and files: Put one bit of text between text collected for matches from the same file, and another bit of text between matches collected from different files. The text to be put between matches from different files is only used when saving text from multiple files into a single file.  K( d. e3 _* D/ r6 [3 W' s7 k
Collect Headers and Footers
1 p  f) u  `0 N* W3 ]& E0 ]Add a header and footer to the files into which the collected text is saved. When collecting into a single file, you can also add a header and footer to the block of text collected from each file searched through.
: S  n/ P0 \7 n/ O6 |1 @) [: d* J- b9 r& t/ y0 }
Expand Placeholders  w) ]( V$ y8 }  t
Expand path placeholders as well as action-related and file-related match placeholders in file headers and footers. In source file headers and footers, path placeholders represent the path to the file that the matches were found in. In target file headers and footers, they represent the file that the collected text is written to.
; m# I/ ~3 P7 z* b* {8 z8 C
8 `' y* e7 C' m8 v0 j: u, `The match placeholder %MATCHCOUNT% can be used in source file footers to indicate the number of matches found in each source file. %MATCHCOUNT% can be used in target file footers to indicate the number of matches written to each target file. %FILECOUNT% can be used in target file footers to indicate the number of source files that had their matches written to that target file.
$ U: g) v" y9 C; h7 N4 c* X& M; n( m, r' g7 k
Select Text to Edit
9 G/ z/ o1 e; S0 Z9 f- t5 gSelect the text you want to edit in the edit box to the right of this list. Which matches are available depends on the choices you make for "between collected text", "collect headers and footers", and "target file creation".7 F1 Z: o2 `0 \# `0 r/ N: {

0 u% `$ Q* Z9 N/ ^& P. nBetween matches: Text to be put between collected matches, whether they're from the same file or from different source files.
+ O  `5 ^7 F6 q/ ^4 m. Z9 QBetween matches from the same file: Text to be put between matches collected from a single source file.: l  h  ]3 m4 [/ k
Between matches from different files: Text to be put between the blocks of matches collected from different source files, when they are being saved into a single target file.% a# }1 S2 m. L8 B) d- K
Source file header and footer: Text to be put before and after a block of text collected from a single file. Can use path placeholders to insert the path to the source file. Used when creating a separate target file for each file, as well as when collecting text from multiple sources into a single target file.
; U7 {& k' D9 o* b9 @Target file header and footer: Text to be put at the start and the end of each file created by the collect data action. Only used when collecting text from multiple source files into a single target file.
- q$ x+ a0 U5 T1 s$ DExamples: Compile indices of files and Generate a PHP navigation bar
' ?+ C& i2 M2 \; I6 X4 x% ]/ A0 L+ Q3 X/ t% l6 r
Discuss
# o1 p. t" }/ }' m* B" N4 n& w
* k" y% M; n/ G% R* ZStart or join the conversation on the topic "Docs: Action Part: Collect Between" in PowerGREP's discussion forum.
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

小黑屋|手机版|Archiver|PDAWIKI |网站地图

GMT+8, 2024-4-26 06:10 , Processed in 0.028603 second(s), 8 queries , MemCache On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表