r2 - 26 Oct 2003 - 06:27:03 - PeterThoenyYou are here: TWiki >  Support Web > BetweenTwoWords
Tags:
, create new tag

Question

How would be the pattern to extract a chunk of text between two arbitrary words that may or not be in the same line. For example:

Welcome to TWiki, a flexible, powerful, 
and easy to use Web-based collaboration platform. 

Use TWiki to run a project development space, 
a document management system, 
a knowledge base, or 
any other groupware tool, on an intranet or on the internet. 

Letīs say I want the text between powerful and tool including both words

powerful, 
and easy to use Web-based collaboration platform. 

Use TWiki to run a project development space, 
a document management system, 
a knowledge base, or 
any other groupware tool

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Red Hat Linux release 6.2 (Zoot) Kernel 2.2.14-5.0smp
Web server: Apache 3.0.99-563
Perl version: 5.005, 5.6.1
Client OS: MS Windows 98SE,
Web Browser: IE 6

-- AntonioVega - 09 Oct 2003

Answer

Do an INCLUDE with a pattern; the pattern search goes over multiple lines. Here is how to grab the text from your example on this topic:

%INCLUDE{ "%TOPIC%" pattern="^.*?(powerful.*?tool).*" }%

does this:

powerful, and easy to use Web-based collaboration platform.

Use TWiki to run a project development space, a document management system, a knowledge base, or any other groupware tool

IncludeTopicsAndWebPages has more.

-- PeterThoeny - 26 Oct 2003

Edit | WYSIWYG | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
 
Powered by TWiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback SourceForge.net Logo