FrontPage 

TB Wiki

Login

TestWebSedProcessor in 'raw' format

{{TableOfContents}}

Following is output from the WebSed processor.  

Data for this test is on the page [[WebSedTestData]]
----
= Test different sources =
In the examples below, a different page
(either external or internal) is parsed
to find Tim's phone number.

== Parse a local page ==
Result parsing a single field from a local page:

The following lines should match:
----
{{{#!WebSed
!WebSedTestData
phone=^phone\s*=\s*(.*)
---
Tim's phone number is %%(phone)s
}}}
----
Tim's phone number is 555-6895
----
== Parse from a localhost URL ==
Result parsing a single field from a url (http://bird.org/tbw-files/UserTimTestWebsed.html)

The following lines should match:
----
{{{#!WebSed
http://bird.org/tbw-files/UserTimTestWebsed.html
phone=^phone\s*=\s*(.*)
---
Tim's phone number is %%(phone)s
}}}
----
Tim's phone number is 123-4567
----


== Parse from a fixed external URL ==
Result parsing a single field from a url
 * from page: http://www.embeddedlinuxconference.com/files/samplefile.txt

The following lines should match:
----
{{{#!WebSed
http://www.embeddedlinuxconference.com/files/samplefile.txt
type=^.*sample\s*(\w*)\s*file
---
The type of sample is: "%%(type)s"
}}}
----
The type of sample is: "text"
----

= Test different match specifications =
== simple match expressions ==
== multi-line matches (endpat) ==
The following sections should match:
----
{{{#!WebSed
!WebSedTestData
block=^BEGIN()
block_endpat=^END()
---
The lines inside the block are:<br>
%%(block)s
}}}
----
The lines inside the block are:{{BR}}
  this is multi-line data;
  this is the second line of multi-line data

----



== context-sensitive matches ==
This section tests the use of precursors.

The following lines should match:
----
{{{#!WebSed
!WebSedTestData
black_animal=black (\S*)
was_eaten=ate a (\S*)
was_eaten_precursor=black_animal
when=(.+.+)
when_precursor=was_eaten
where=(.+.+)
where_precursor=when
---
The %%(black_animal)s did eat a %%(was_eaten)s; place: %%(when)s;
at a location best described as "%%(where)s"
}}}
----
The cat did eat a rat; place: late at night;
at a location best described as "upon a mat"
----

The following lines should match:
----
{{{#!WebSed
!WebSedTestData
brown_animal=brown (\S*)
was_eaten=ate a (\S*)
was_eaten_precursor=black_animal
when=(.?)
when_precursor=was_eaten
where=(.?)
where_precursor=when
---
The %%(brown_animal)s had %%(was_eaten)s %%(when)s
at a location best described as "%%(where)s"
}}}
----
The squirrel had !not found! !not found!
at a location best described as "!not found!"
----









== anonymous sequences ==
The following lines should match:
----
{{{#!WebSed
!WebSedTestData
=the (.*) bike was (.*)
---
I believe that the %%s bicycle might have been %%s.
}}}
----
I believe that the red bicycle might have been ruined in a crash.
----

== controlling the search space ==

== empty format spec ==
The following sections should match:
----
{{{#!WebSed
!WebSedTestData
phone=^phone\s*=\s*(.*)
email=^e_mail\s*=\s*(.*)
}}}
----
 * email: tim@bird.org
 * phone: 555-6895

----

== missing match ==
This tests when a match is missing from the source data

The following lines should match:
----
{{{#!WebSed
!WebSedTestData
missing=this line does not appear on the test (page)
---
The missing data is: "%%(missing)s"
}}}
----
The missing data is: "!not found!"
----















TBWiki engine 1.9.2 by Tim Bird