removing-multiple-blocks-of-records.rex |
Pipelines v2.1 |
.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10... |
**** Top of file ****
1
2 /* The following pipeline reads the file: startup.ini and removes all of the [TCPIP] sections.
3 This pipeline construction can be used to remove any number of blocks of records that begin and
4 end with a known label, ie) character or characters. In this example, each block of records that
5 start with the expression '\[tcpip([0-9])*\]' and end with the record immediately before a record
6 which starts with the character '[', are removed. */
7
8 Address Rxpipe
9
10 'pipe (endchar ? regex 3)',
11 '< &installdrive:\&installpath\examples\input\startup.ini',
12 '| change 1 /[/ /@[/', /* Insert '@' in front of any '[' char. */
13 '| split after str /@/', /* Split after '@' character. */
14 '| a: between casei() reg /\[tcpip([0-9])*\]/ /@/', /* Discard records.. */
15 '| hole', /* ..up to the next marker. */
16 '?',
17 'a:',
18 '| nlocate 1 /@/', /* Discard any marked records. */
19 '| cons' /* Display records on the console. */
20
21 Say 'Hit Enter to close..'
22 Parse Pull
23
24 Exit 0
**** End of file ****
Console
output |
.....|...+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+....10...
1 [FILES]
2 Order=ba
3 a=d:\file a1.txt
4 b=d:\file b3.txt
5
6 [SPOOL]
7 Header=2e
8 State=0a
9
10 [FILES1]
11 Order=ba
12 a=d:\file a9.txt
13 b=d:\file b2.txt
14
15 [SPOOL1]
16 Header=2e
17 State=0a
18
19 [FILES2]
20 Order=ba
21 a=d:\file a10.txt
22 b=d:\file b0.txt
23
24 [SPOOL3]
25 Header=2e
26 State=0a
27 Hit Enter to close..
|