create new tag
, view all tags


I am working on a training log application and use select controls throughout. I took the advice of the forms documentation and create tables that can be used to generate select lists for TWiki forms. I also want to use these same tables for HTML forms.

The TWiki documentation recommends creating tables for this purpose in this format:

| *Name*            |
| NoDisclosure      |
| Public Supported  |
| Public FAQ        | 

Public Supported
Public FAQ

I have so far had no luck in writing a search that would extract the contents of the columns minus the header column.

Here is my best attempt so far:

|  Exercises: | <select size="1" name="WeightRoomExercises"> %SEARCH{"\|\s*[a-z0-9]*.*" topic="WeightRoomExercises" type="regex" multiple="on" nonoise="on" format="<option>$pattern(^\|\s*([a-z0-9\s\(\)]*?[a-z0-9\(\)])\s*\|.*)</option>"}% </select>  |

The problem with the foregoing are:

  • creates an empty pair for the header column
  • puts each pair on a separate line

The table I use looks like this:

Leg Press
Mule Kick
Leg Curls
Rotary Hip (pull)
Rotary Hip (push)
Calf Raises
Lat Pull Downs
Seated Rows
Chest Press
Upright Row

The result of this search is:

<input disabled="disabled" type="hidden" name="topic" size="70" value="WeightRoomExercise00001DetailAUTOINC00" />
|  Exercise: | <select size="1" name="WeightRoomExercises"> <option></option>
<option>Leg Press</option>

<option>Mule Kick</option>
<option>Leg Curls</option>
<option>Rotary Hip (pull)</option>
<option>Rotary Hip (push)</option>
<option>Calf Raises</option>
<option>Lat Pull Downs</option>
<option>Seated Rows</option>

<option>Chest Press</option>
<option>Upright Row</option>
<option>Crunches</option> </select>  |

Consequently, TWiki rendering does not see the result as a line in a TWiki table.

I know how to parse this in Perl but so far have not been able to coax var%SEARCH to do my bidding.

I am aware of similar examples in the SearchCookBook but these don't quite fit the bill.


TWiki version: TWikiRelease04x01x02
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Mac OS X
Web server: Apache
Perl version: 5.8.6
Client OS: Mac OS X
Web Browser: Camino
Categories: Forms

-- JohnPoplett - 11 Nov 2007


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.

your regex should work with:

|  Exercises: | <select size="1" name="WeightRoomExercises"> %SEARCH{"\|\s*[a-z0-9]*.*" topic="WeightRoomExercises" type="regex" multiple="on" nonoise="on" format="<option>$pattern(^\|\s*([a-z0-9\s\(\)]*?[a-z0-9\(\)])\s*\|.*)" separator="</option>"}% </select>  |

Others will help you with filtering the headers more clearly.

-- FranzJosefGigler - 11 Nov 2007

Hi, Franz!

Thanks for your suggestion! I had overlooked the separator parameter. I understand better why I get a blank first option. The regex in the plain string in a varSEARCH is a topic selector! It doesn't select text within a topic. The regex pattern in $pattern selects text within a topic. My $pattern regex results in an empty string for the first line.

It would be nice if there was an option so the format string is only emitted when the result of the pattern regex is non-empty. Anyway, I am getting usable results now.

Thanks again.


-- JohnPoplett - 12 Nov 2007

Change status to:
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2007-11-13 - JohnPoplett
  • 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.