-
Notifications
You must be signed in to change notification settings - Fork 86
/
vmod_str.vcc
55 lines (35 loc) · 1.44 KB
/
vmod_str.vcc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# Copyright (c) 2016 Guillaume Quintard
#
# Author: Guillaume Quintard <guillaume.quintard@gmail.com>
#
# (vmodtool requires this format.)
#
$Module str 3 "Str VMOD"
DESCRIPTION
===========
$Function INT count(STRING s)
Returns the number of ascii characters in S, or -1 if S is null.
$Function BOOL startswith(STRING s1, STRING s2)
Returns true if S1 starts with S2.
$Function BOOL endswith(STRING s1, STRING s2)
Returns true if S1 ends with S2.
$Function BOOL contains(STRING s1, STRING s2)
Returns true if S1 contains S2.
$Function STRING take(STRING s, INT n, INT offset = 0)
Returns a string composed of the N first characters of S. If S is shorter than N
character, the return string is truncated. If S is NULL, NULL is returned.
A negative offset means "from the end of the string" and a negative n means
"left of the offset".
$Function STRING reverse(STRING s)
Reverse s.
$Function STRING split(STRING S, INT n, STRING sep = " \t")
Split s and return the n-th token. Characters in sep are separators. A negative
n indicate "from the end of the string".
$Function BOOL token_intersect(STRING str1, STRING str2, [STRING separators])
Checks if the set tokens in one string intersects the set of
tokens in the other string. In other words, it returns true if
there is a token which exists in both strings.
If the separators argument is not supplied, the space and comma
characters are the separators. Empty tokens are ignored in both
strings.