[syslog-ng] [PATCH] basicfuncs: Implement a $(substr STR START [LEN]) template function.

Balazs Scheidler bazsi at balabit.hu
Sun May 1 23:12:49 CEST 2011


On Sun, 2011-05-01 at 10:12 +0200, Gergely Nagy wrote:
> This is an implementation of a $(substr <string> <start> [<len>])
> template function, where the first argument is the string we want to
> extract a part from, the second is the starting offset, and the third,
> optional is the length of the substring we want to extract.
> 
> If no length is specified, then the substring will be extracted from
> the desired offset until the end of the original string. Offset 0
> means the start of the string.
> 
> Negative offsets/lengths works in a manner similar to other
> implementations:
> 
> - negative offset means "start that many characters counting from the
>   end of the string", with -1 being the last character
> - negative length means "return substring from desired start up to
>   that many characters from the end of the string"
> 
> Signed-off-by: Jakub Jankowski <shasta at toxcorp.com>
> Signed-off-by: Gergely Nagy <algernon at balabit.hu>

Applied, thanks.

I've added some unit testcases & they all passed flawlessly.

-- 
Bazsi




More information about the syslog-ng mailing list