Question
I have learned several ways to query forms, they all work. But, for heavens sake, I don't know why!!!
For example, this:
%SEARCH{ "[S]chool Type.*value=.[I]nstrumentality"
What do the brackets around "S" and "I" mean? Why does value have a "*" in front of it? Why is there a "." before the search value, "Instrumentality?"
And, this:
META\:FIELD.*?SchoolType.*?Instrumentality"
What does
*? mean? I know if I remove them, it no longer works.
I guess I should be happy that it works, but it bugs me not to understand and I have looked all over the place. Where is the documentation on this?
Environment
--
JohnGee - 10 Jun 2008
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
This is a
RegularExpression search question. Regular expressions are more powerful than literal search, but they are quite geeky and need some time to learn. TWiki 4.2 offers a
QuerySearch that makes advanced somewhat searches easier.
To your questions:
-
[aiueo] finds exactly one vowel, [S] finds exactly one character S. So why a single char in [...]? That is to exclude the search page from showing up in a search result. The same can be achieved with an excludetopic parameter. These two searches are identical
%SEARCH{ "[S]chool Type.*value.[I]nstrumentality" type="regex" ...=
%SEARCH{ "School Type.*value.Instrumentality" type="regex" excludetopic="%TOPIC%" ...=
-
.*? is a cautious scan forward ("non greedy search"), skipping over any character until the first pattern following it is found. The greedy .* pattern scans forward and finds the last pattern.
Learn more at
RegularExpression,
Wikipedia:Regular_expression
,
http://www.perl.com/doc/manual/html/pod/perlre.html
--
PeterThoeny - 10 Jun 2008