Question
Is there any way using the
SEARCH function combined with
$pattern (or something else) to extract only part of a field value?
Example:
There is a field value called
Topic with a value
Sandbox.TestCase.
How could I extract only the webname (
Sandbox in this example) from the field value?
Thanks in advance.
Environment
--
SebastianKlus - 06 Aug 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.
I am not completely sure what you want to achieve. Are you trying to format the
result of a search by displaying only a part of a form field? That's not easy, because the formatting features of
FormattedSearch do not know about semantics like "Web" or "Topic" within a form field.
SpreadSheetPlugin might be able to do the trick, with some amount of
$percnt voodoo to make sure that the calculation is done on the result, and not on the query.
The web and topic of a search hit are available as separate formatting variables
$web and
$topic, so maybe you don't need to extract them from formfields at all.
--
HaraldJoerg - 06 Aug 2008
Hello Harald,
I already figured it out with
SpreadSheetPlugin before, but was curious if it could be handlede with only TWiki means. Because the
%CALC% solution looks horrible
%INCLUDE{"TWiki.TranslationNote" section="%FORMFIELD{"Language"}%" ORIGIN="%FORMFIELD{"Origin"}%" REVISION="%FORMFIELD{"Revision"}%" ORIGINWEB="%CALC{"$REPLACE(%FORMFIELD{"Origin"}%,$FIND(., %FORMFIELD{"Origin"}%),$LENGTH(%FORMFIELD{"Origin"}%), )"}%" ORIGINTOPIC="%CALC{"$REPLACE(%FORMFIELD{"Origin"}%,0,$FIND(., %FORMFIELD{"Origin"}%), )"}%"}%
--
SebastianKlus - 08 Aug 2008
I was able to pass data to a javascript script by using the % INCLUDE % tag in the middle of the data section definition. Maybe you can persue this avenue. Javascript langage seems to be more convenient than
SpredSheetPlugin for this objective. Note that this might not follow your constraint of using a technique inside a % SEARCH %.
AlainLavoieDexto
--
AlainLavoieDexto - 18 Aug 2008