Extracts middle portion of the text between any two strings.
[middle startafter=x&endbefore=y]Any Text[/middle][middle startafter=<body>&endbefore=</body>]
<html>
<head>
</head>
<body>
Hi There
</body>
</html>
[/middle]
Parameter | Description |
---|---|
startafter | String of text characters to search for defining the beginning of the text to be returned. All preceding text (and the StartAfter text itself) will be ignored. |
endbefore | String of text characters to search for defining the end of the text to be returned. If several occurence of the search string appear in the text, then the last one only will be relevant. All following text (and the EndBefore text itself) will be ignored. |
startbefore | (Available from v8.2) String of text characters to search for defining the beginning of the text to be returned. All preceding text will be ignored. |
endafter | (Available from v8.2) String of text characters to search for defining the end of the text to be returned. All following text will be ignored. |
[text]myVar=abc/def/ghi/jkl/&mno/pqr/>/stu/vwx/>yz?[/text]
[middle startafter=f/&endbefore=/j][myVar][/middle]
[middle startafter=f/&endbefore=/][myVar][/middle]
[middle startafter=f/&endbefore=[url]&[/url]][myVar][/middle]
[middle startafter=f/&endbefore=&][myVar][/middle]
[middle startafter=f/&endbefore=/>][myVar][/middle]
[middle startafter=Subject: &endbefore=%0A&endcount=-1]
Message-Id: <1874F5DF-301E-4560-8C37-63BD903EA7E4@zarcrom.com>
From: Joshn Doe
To: talk@webdna.us
Content-Type: text/plain; charset=US-ASCII; format=flowed
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0 (Apple Message framework v924)
Subject: [WebDNA] test message
Hello, this is a test
[/middle]
startcount and endcount can be positive or negative. A negative number counts from the opposite end it normally counts from. Positive numbers always count from the traditional direction that old WebDNA versions counted from. If you do not provide the startcount/endcount, they default to 1.
A startcount of -2 means "find the startafter/startbefore that is 2nd from the end of the string". Likewise, giving endcount of -2 means "find the endbefore/endafter that is 2nd from the beginning of the string".
When something isn't found, or if it isn't found enough times, then it ignores it. So for example, [middle startafter=q&startcount=10]xyz[/middle] will return xyz. This is the behavior of [middle] in previous versions, so it retains compatibility.
[text]myVar=abc/def/ghi/jkl/&mno/pqr/>/stu/vwx/>yz?[/text]
1.- [middle startbefore=f/&endafter=/j][myVar][/middle]
2.- [middle startafter=/&startcount=2][myVar][/middle]
3.- [middle endbefore=/&endcount=3][myVar][/middle]
4.- [middle endbefore=/&endcount=-3][myVar][/middle]
5.- [middle startbefore=/&endafter=/][myVar][/middle]
6.- [middle startafter=f/][myVar][/middle]
7.- [middle endbefore=/&startcount=5][myVar][/middle]
8.- [middle startbefore=f/][myVar][/middle]
For #7, the "startcount" is ignored because startcount is only used with "startbefore" and "startafter". Since no startbefore or startafter is provided, there is nothing to use startcount with. The default "endcount" of 1 is used instead since "endbefore" is provided.
DOWNLOAD WEBDNA NOW!
Amazon Web Services (AWS) README for Machine Image ID...
[biotype]BioType is a behavioral biometrics WebDNA function based on ADGS research and development (from version 8...
Download WebDNA ApplicationsWebDNA applications...
F.A.QA compilation of some user's questions...
WebDNA LibrariesA list of available libraries for WebDNA...
Tips and TricksA list of user-submitted tips ...
[addfields db=...
[encrypt][encrypt] and [decrypt] allow you to store sensitive data in your databases without risk of exposing it to prying eyes...
[shell][shell] is a way to use the command line with your webserver...
[array]Array Operation...
[xmlnodes]The behavior of this context is to iterate the child XML nodes of a parent node...
[waitforfile]The server waits until the file appears on disk...