Tags:
create new tag
view all tags

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

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Ubuntu 8.01
Web server:  
Perl version:  
Client OS:  
Web Browser:  
Categories: Search

-- SebastianKlus - 06 Aug 2008

Answer

ALERT! 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 smile

%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

Change status to:
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r6 - 2008-08-19 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.