Changes between Version 9 and Version 10 of RegexIncludeMacro


Ignore:
Timestamp:
Oct 5, 2006 3:36:15 PM (8 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • RegexIncludeMacro

    v9 v10  
    1111 * arg 1 :  url - Like the Include macro except, local files cannot be included[[FootNote(Well, they can if the file resides in /tmp/trac_include/ and no slashes are used in filename.)]] 
    1212 * arg 2 :  format. Either "wiki" or "raw", where wiki does WikiFormatting 
    13  * arg 3+:  <more to come> 
     13 * arg 3+:  "Control arguments". See Control Arguments below. 
    1414 * arg last:The regular expressions MUST be the last argument 
    1515 
    1616Regular expressions are defined as such:[[BR]] 
    17 '&lt;expression&gt;','&lt;replacement&gt;'[[BR]] 
    18 You can use several expressions, seperated by semicolon:[[BR]] 
    19 '&lt;expression&gt;','&lt;replacement&gt;';'&lt;expression&gt;','&lt;replacement&gt;' 
     17'&lt;expression&gt;'/'&lt;replacement&gt;'[[BR]] 
     18You can use several expressions:[[BR]] 
     19'&lt;expression&gt;'/'&lt;replacement&gt;','&lt;expression&gt;'/'&lt;replacement&gt;' 
    2020 
    21 You can also use capture groups. In python (i learned) these are defined as \1,\2 ect. (where in eg. perl its $1,$2) 
     21You can also use capture groups. In python these are defined as \1,\2 ect. (where in eg. perl its $1,$2) 
    2222 
     23=== Control Arguments === 
     24 
     25Control Arguments are defined AFTER the second argument (raw,wiki) and BEFORE the regular expressions. Multiple arguments are seperated by comma.[[BR]] 
     26Example: 
     27{{{ 
     28RegexInclude(http://google.com,wiki,no_anon,use_vars=lower,'Expression'/'Replacement') 
     29}}} 
     30 
     31 use_vars:: 
     32 ''If defined, replace $USER with username in '''URL'''''. (NOT in the included text!). [[BR]] 
     33 use_vars accepts a sub-argument, used change the case of the username. This is one of:[[BR]] 
     34       * upper 
     35       * lower 
     36       * ucfirst 
     37 example: 
     38        use_vars=upper 
     39 
     40 (note: ucfirst is "uppercase first letter only") 
     41 
     42 
     43 no_anon:: 
     44 ''Do not include this page for anonymous users.''[[BR]] 
     45 '''NOTE:''' this is NOT a security feature, as anyone can still read your source code.[[BR]] 
     46 Good feature to not include unneseseary information for anon users. 
     47 
     48 
     49 no_dotall:: 
     50 ''Disable the use of DOTALL option for regular expression''.[[BR]] 
     51 pr. default DOTALL is enabled and this make the dot (".") also include linebreaks 
    2352 
    2453[[FootNote]] 
     
    4473A simple example. Replace all occurences of the word &#34;windows&#34; with the word &#34;Linux&#34; 
    4574{{{ 
    46 [[RegexInclude(http://yourpage.tld,raw,'[Ww]indows','Linux')]] 
     75[[RegexInclude(http://yourpage.tld,raw,'[Ww]indows'/'Linux')]] 
    4776}}} 
    4877 
    4978The next example includes http://www.kernel.org/kdist/finger_banner and wiki-formats the wanted data, and removes the unwanted. Perticulary, i want to only keep the major version information, not patches nor snapshots. 
    5079 
    51 Note how i use 2 regular expression replaces, seperated by ';'. The first expression formats the lines i want to keep, the second deletes the rest. 
     80Note how i use 2 regular expression replaces, seperated by ','. The first expression formats the lines i want to keep, the second deletes the rest. 
    5281 
    5382{{{ 
    54 [[RegexInclude(http://www.kernel.org/kdist/finger_banner,wiki,'The latest ([\w.]+) version [^:]+:\s*([a-z0-9.-]+)',' '''\1''' :: \n  ''\2'' ';'\nThe[ a-zA-Z0-9.:-]+','\n')]] 
     83[[RegexInclude(http://www.kernel.org/kdist/finger_banner,wiki,'The latest ([\w.]+) version [^:]+:\s*([a-z0-9.-]+)'/' '''\1''' :: \n  ''\2'' ','\nThe[ a-zA-Z0-9.:-]+'/'\n')]] 
    5584}}} 
    5685 
     
    6695 
    6796== Known limitations == 
    68  * expressions or replacement-strings cannot contain ';' (that is: tick-semicolon-tick) since that combination is used for splitting the expressions: 
    69  * expressions or replacement-strings cannot contain ',' (that is: tick-comma-tick) since that combination is used for splitting the expression from replacement-string. 
     97 * expressions or replacement-strings cannot contain ',' (that is: tick-comma-tick) since that combination is used for splitting the expressions: 
     98 * expressions or replacement-strings cannot contain '/' (that is: tick-slash-tick) since that combination is used for splitting the expression from replacement-string. 
    7099 
    71100I hope these two combinations are so unlikely, that the limitation wont cause any trouble.