Question
I am trying to keep track my weekly statuses in a wiki topic. I then want to use an inlclude statement to place my weekly status for one week from my topic into the summary status for the team for the week.
I am trying to do an include with a regular expression. However, the regexp does not seem to be applied correctly. It may be my lack of knowledge about Perl Regular Expressions. I would provide all my version information, however, I am seeing the same behavior here on twiki.org. I want to capture the text in
IncludeRegExpSampleTopic between the markers AAA and BBB. However, theINCLUDE regexp I thought should be used AAA.*BBB is including all the text EXCEPT between AAA and BBB. (See below)
So my questions are:
- Why doesn't below work?
- The text I am tring to grab from my status topic spans multiple lines. Can I use regexp with INCLUDE to grab multiple lines? I have read in HowToRegexMultipleLines that . will not match the newlines, but it sounds like the workaround proposed would be external from the INCLUDE command.
Thank you for your help with this.
Results of:
%INCLUDE{"IncludeRegExpSampleTopic" pattern="AAA.*BBB"}%
This is text before
This is text after
Results of:
%INCLUDE{"IncludeRegExpSampleTopic" pattern="(AAA.*BBB)"}%
This is text before
AAA
This is multiple lines
of text inside
BBB
This is text after
Results of:
%INCLUDE{"IncludeRegExpSampleTopic" pattern="~ /AAA.*BBB/"}%
Results of:
%INCLUDE{"IncludeRegExpSampleTopic" pattern="(~ /AAA.*BBB/)"}%
--
MichaelMathis - 10 Sep 2002
Answer
You almost got it, make sure to scan the whole topic. Do this:
%INCLUDE{ "IncludeRegExpSampleTopic" pattern="^.*?AAA(.*)BBB.*" }%
To get this:
This is multiple lines
of text inside
Yes, you can INCLUDE multiple lines with a regex.
--
PeterThoeny - 11 Sep 2002
Just fooling around with the formatting to actually show the searches attempted and their results. Will also modify
IncludeRegExpSampleTopic to include multiple lines to see if the regex above already works for multiple lines or requires some sort of modification. I'll be back!
I'm back -- the regex as is works for multiple lines! (So I left the example with multiple lines to demonstrate that.)
Aside: "=" "=" is not the same as <verbatim> </verbatim> -- is it the same as <pre> </pre> or is it a third variation of behavior? (Some day I'll determine that for sure, for now it's just "idle" curiosity.)
--
RandyKramer - 12 Sep 2002