Tags:
create new tag
view all tags

SID-00194: Regex query to display text from table cell

Status: Answered Answered TWiki version: 4.2.0 Perl version:
Category: CategorySearch Server OS: Last update: 16 years ago

I am using a formatted search to retrieve and display all topics with a certain company name in a specific table cell. These topics consist of editable tables from which I want to display the contents of a specific cell (Title) in the search results.

I succeeded in searching for the companyname with a regular expression, using the examples on this site, but with my very limited regex experience I cannot get the display of the correct cell to work. I'd be grateful for any suggestions.

This is an example of the table in the target topics:

Patent reviewed by Me  
Assignee Company  
Title Patent title  
Abstract Patent abstract.  

The cell I'd like to display the data from is the cell next to Title (Patent title)

And this is the formatted search query, which retrieves the correct topics, but does not display the title. The $summary only dispays the cell I searched for (Company)

%SEARCH{ "^\|[^\|]*\| *Company.* *\|"  type="regex" multiple="on" nosearch="on" topic="Patent* " excludetopic="%TOPIC%" nototal="on" format="    |[[$topic]] |  $pattern(.*?Title: *\|*(.*?) *\|.*) | $summary |"  header="| *Topic* | *Title* | *Summary:* |"}%

-- JurriaanHehenkamp - 17 Mar 2009

Discussion and Answer

This:

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

Produces: Patent title

Modify the topic parameter on your site to be

topic="Patent* "

-- EnriqueCadalso - 17 Mar 2009

Enrique thanks,

Your query gives me the titles of all topics, however what I need is to have the titles (and topics) of those topics that have "Company" in the assignee field (and Patent* as topic). The original query gives me the correct topics, however I'd like to have the titles next to the topic in this format:

Patent1 Title1 Abstract1
Patent2 Title2 Abstract2

I don't know if this is at all possible with the regex search. My current query displays the table row with "Assignee Company" in it. Is it possible to display the next row in the table from the place your query has found the hit? Or should this be a nested query?

-- JurriaanHehenkamp - 17 Mar 2009

I suggest you to implement a TWiki application using a form with this fields. Otherwise even when you manage to find the right search query it will become too difficult to maintain consistency in the data, as far as it will be not structured like the data we can have in a form. Using twiki forms will make it easier to perform searches, filters and sorting of any kind, and to produce a richer variety of reports. And no need to bother with the regex syntax.

-- EnriqueCadalso - 17 Mar 2009

I agree with you, however in this case I preferred to use the tables because of the edittable options (giving the users the easy option to select from options). The table above is just a simple example of the more expanded tables. I do use templates for this so the topics are consistent in table structure.

Do you think it is at all possible to do this (get the text from the next line in the table) or am I just wasting my (and your) time?

Thanks

-- JurriaanHehenkamp - 17 Mar 2009

Maybe a regex guru. But (from documentation of search function) with multiple=on the $pattern feature works only on the line found, so if you found and Assignee/Company match it wont be on the same line of Title/The title pair. In short, it will be tricky. BTW you can implement forms "giving the users the easy option to select from options". You can even use regular html forms, with the design you want.

-- EnriqueCadalso - 17 Mar 2009

You can get the text from the next line in the table with a 'nested search', so that each of the topics resulting from your search for Company are then searched for Abstract. See FormattedSearch for details.

-- SeanCMorgan - 17 Mar 2009

I also suggest to create a TWikiForms based application. It is much more structured, and queries can be done easily. It is also possible to create custom edit forms, see screenshot and outline at SID-00029.

-- PeterThoeny - 18 Mar 2009

Thanks all, I would certainly use forms if I would set it up again, however there are already 50+ topics with these tables created.

Enrique: The multiple=on was a copy error, there is only one title row in each topic, does that allow displaying the next line in the table?

Sean:I have tried nested search, but I am having trouble with escaping the second search pattern. Should I escape the escapes as well?


%SEARCH{ "^\|[^\|]*\| *Company.* *\|"  type="regex" nosearch="on" topic="Patent* " nototal="on" format="|[[$topic]] | %SEARCH{ \"^\| \*Title\* \|\" topic=\"$topic\" type=\"regex\" nosearch=\"on\" nototal=\"on\" format=\"$pattern(^\| \*Title\* \| *(.*?) *\|.*)\" }%" header="| *Topic* |  *Title:* |"}%

If this doesn't work I'll stick with displaying the topics and general summaries. Thanks again for all suggestions.

-- JurriaanHehenkamp - 18 Mar 2009

It is possible but, I repeat, it is a blind alley. This is the nested search. Testing with Company2 it wont show


%SEARCH{ "^\| \*Assignee\* \| Company " topic="%TOPIC%" type="regex" multiple="on" nosearch="on" nototal="on" format="$percntSEARCH{ \"^\| \*Title\* \|\" topic=\"$topic\"  type=\"regex\" multiple=\"on\" nosearch=\"on\" nototal=\"on\" format=\"$dollarpattern(^\| \*Title\* \| *(.*?) *\|.*)\"  casesensitive=\"on\" type=\"regex\" nosearch=\"on\" nototal=\"on\"    }$nop%" }%

Testing with "Company ": Patent title

Testing with "Company2":

-- EnriqueCadalso - 18 Mar 2009

Please note that nested searches can be very slow. You are not doing two searches, but a secondary search for each primary search hit.

-- PeterThoeny - 18 Mar 2009

Thanks a lot Enrique, it works perfectly! In the future I will stick with forms... but for now this saves me a lot of time and effort.

-- JurriaanHehenkamp - 18 Mar 2009

      Change status to:
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.
SupportForm
Status Answered
Title Regex query to display text from table cell
SupportCategory CategorySearch
TWiki version 4.2.0
Server OS

Web server

Perl version

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2009-03-18 - SeanCMorgan
 
  • 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.