June 2000
Intermediate to advanced
556 pages
8h 45m
English
In this section, we illustrate xgrep in action and, on the way, learn some more useful regular expression syntax.
An xgrep invocation to find simple XML start- and end-tags is shown below.
CD-ROM reference=7065.txt C>type test.xml <Greeting> Hello <b>World</b> <Farewell> Goodbye</Farewell></Greeting> CD-ROM reference=7066.txt C>python xgrep.py -p "<.+?>" test.xml test.xml:<Greeting> test.xml:<b>World</b> test.xml:<Farewell> test.xml:<Farewell></Greeting>
The pattern simply looks for a start-tag or an end-tag. If there is more than one match per line, no extra actions are taken. To see the exact reason for a match occurring, use the -m option.
CD-ROM reference=7067.txt
C>python xgrep.py -m -p "<.+?>" test.xml test.xml:[<Greeting>] ...Read now
Unlock full access