Tags:
create new tag
view all tags

Question

I want to use "search{....}"on my topic which is a formatted table .This topic is not a form so i cant be using formfield parameters

Name Country Language
abc pqrs uv
def lmn poq

The search has to return a table which has only

Name
abc
def

I have written a search but it gives me the table as it is. Am not able to extract a single column with values from the table

Most of the examples on a search are for a form. But i have a simple table entries in the topic

Please help

Environment

TWiki version: TWikiRelease04x02x00
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Solaris
Web server: Apache
Perl version:  
Client OS:  
Web Browser: Firefox 2.0.0.4,Mozilla
Categories: Plugins

-- PrathibaRao - 02 Jul 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.

Prathiba: You can probably use regex to do that. Just set type="regex" in your SEARCH variable, and come up with the regex to find the row you want. I can't help with the last part, as I suck at regex. RegularExpression may be a starting point, or the Wikipedia article.

-- AaronFuleki - 02 Jul 2008

i do not want the row values ..I want the column values.A table has multiple columns and i want one particular column which has 4 values. I cant use Filter Plugin or RenderTable Plugin as it is not activated in my twiki. So i need help on regular expressons.........

-- PrathibaRao - 03 Jul 2008

Prathiba, you're asking for columns, but your example shows the row data. Which do you actually want?

-- DavidWolfe - 03 Jul 2008

i want column values.. and i am stil stuck with regular expression pattern.

-- PrathibaRao - 04 Jul 2008

i have changed my table and i want the column values. i dont know as to how to write a regex expression that will identify the header and extract values from that...

-- PrathibaRao - 04 Jul 2008

Look at the search patterns explained in the SearchPatternCookbook Topic in Twiki Web : "Extract values from a table " .. All you need is there, and you'll find the reponse there. If you deal with more complicated searchs, remember that a "formatted search" is like a cat pipe grep pipe awk : you can open a terminal and type cat twiki_dir/data/your_web/your_topic.txt and then use grep : this will help to find the regexp you need ..Did this help ?

-- OlivierThompson - 05 Jul 2008

thanks Olivier. But if you see the problem definition in the link which u sent it says " Topic with a table defining entries in a TWikiForm " But my table is not defined in a form..So the eg do not help me...

-- PrathibaRao - 07 Jul 2008


When you do a search without form fields in the format clause, you have to find two appropriate regexps, one regexp for grep, in the search clause of the SEARCH, and the other regexp to print the required fields, in the format clause of the SEARCH. So the SEARCH will look like ( on a single line ) :
%SEARCH{ "Here comes RegExpOne to grep lines" topic="%TOPIC%" type="regex" \
multiple="on" nosearch="on" nototal="on" \
format=" | $pattern(Here comes RegExpTwo to select fields) |" }%

However if you just want the first field of your table up there, the (a) solution will be very closed to the example shown in the SearchPatternCookbook. Do the two spaces at the beginning of the third line ( "def" ) matter for you ? I will suppose they do not ..

%SEARCH{ "^\| .*\|.*\|.*\|" topic="HowToUseSearchForATwikiTopic" \
type="regex" multiple="on" nosearch="on" nototal="on" \
format=" | $pattern(^\| *(.*?) *\|.*)|" }%

and the result will be :

Name
abc
def

-- OlivierThompson - 07 Jul 2008

thanks for the help olivier. If i want multiple columns of my choice i.e 1 st and 3rd column or 3rd and 5 th column then i should be able to apply similar kind of pattern and get it right??

-- PrathibaRao - 08 Jul 2008


Here it is for 1 st and 3rd column : using the $pattern keyword in the SEARCH clause will cause the regexp look for the subexpression matched by \1 : therefore, I use the $pattern keyword twice. This is my code :

%SEARCH{ "^\|.*\|.*\|.*\|" topic="HowToUseSearchForATwikiTopic" type="regex" multiple="on" nosearch="on" nototal="on" \
format=" | $pattern(^\| *(.*?) *\|.*)| $pattern(^\| .*\|.*\|(.*?)\|.*)| " }%

and the result is ..

Name Language
abc uv
def poq

See also http://freshmeat.net/projects/visualregexp/ : this is a graphical tool that wil run on linux or windows

-- OlivierThompson - 10 Jul 2008

thank olivier for the help

-- PrathibaRao - 15 Jul 2008

Change status to:
Edit | Attach | Watch | Print version | History: r12 < r11 < r10 < r9 < r8 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r12 - 2008-07-15 - PrathibaRao
 
  • 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.