Question
I am trying to write a $pattern in a
FormattedSearch that will extract "value" from a META tag. For example:
%META:FIELD{name="IsoSecPolSubSection" title="IsoSecPolSubSection" value="1.5"}%
There are a number of topics with the above META:FIELD and all have a name of the form [something]SubSection. I am trying to build a pattern that will find this field with
SubSection in it and extract the #.# from the "value". Caveat: the "value" can be almost arbitrary -- I would simply like to extract what is between the beginning " and the ending ".
Thanks!
BTW, is there a way to "debug" pattern?
Environment
--
SteveRJones - 08 Aug 2003
Answer
Hm, your example was slurped into the form when you saved the topic, so I do not see what it was. Escape the META tag with
<nop> in between. I restored it the way I assumed it was.
You cannot apply a
$pattern() to a form field, those can only be applied to the main text of the topic. Use
$formfield() instead, e.g. for the field named
IsoSecPolSubSection write:
| $topic | $formfield(IsoSecPolSubSection) |
If you have a field who's name changes but is of similar nature (e.g. defined by multiple form), and assuming there is only one at a time: You can extract the field of similar name by append all possible variants, e.g. write:
| $topic | $formfield(FooSubSection)$formfield(BarSubSection) |
This works because missing form field names are ignored.
--
PeterThoeny - 09 Aug 2003
Peter, thank you very much - my assumption about $pattern was that it would search through the entire text as one sees it when rendering a page via raw=debug. Thank you for answering that question.
As for the solution, yes, your second example will work as there are fields of the same datatype and context, just applied to different field names. I will give this a go.
The sad part is, I'll have to find another example on which to figure out $pattern! regex still mistifies me!
One last question: I
think I can apply a $SEARCH and look for anything in a topic, including META text -- true? If so, why won't pattern work and allow one to extract? Or, am I wrong (I don't have my twiki spource in front of me right now.)
--
SteveRJones - 09 Aug 2003
The %SEARCH works on the whole topic including meta data (it is a grep search on the file. However, the $pattern is applied to the topic body only, excluding meta data. This is the current implementation.
--
PeterThoeny - 09 Aug 2003
Ah, hence the source of my confusion - I basically extrapolated the behavior of %SEARCH and assumed that $pattern would work the same way -- anything found by %SEARCH could be manipulated by $pattern. thank you for clearing that up.
--
SteveRJones - 11 Aug 2003