Next: String formatting, Previous: String transformation, Up: Library [Contents][Index]
Returns a copy of str with the characters from chars escaped, i.e. prefixed with a backslash. If chars is not specified, ‘\"’ is assumed.
escape('"a\tstr"ing') ⇒ '\"a\\tstr\"ing' escape('new "value"', '\" ') ⇒ 'new\ \"value\"'
Performs the reverse to ‘escape’, i.e. removes any prefix backslash characters.
unescape('a \"quoted\" string') ⇒ 'a "quoted" string'
Returns the domain part of str, if it is a valid email address, otherwise returns str itself.
domainpart("gray") ⇒ "gray" domainpart("gray@gnu.org.ua") ⇒ "gnu.org.ua"
Returns the index of the first occurrence of the string t in the string s, or -1 if t is not present.
index("string of rings", "ring") ⇒ 2
Optional argument start, if supplied, indicates the position in string where to start searching.
index("string of rings", "ring", 3) ⇒ 10
To find the last occurrence of a substring, use the function rindex (see rindex).
Converts str, which should be a valid time interval specification (see time interval specification), to seconds.
Returns the length of the string str in bytes.
length("string") ⇒ 6
Removes ‘<’ and ‘>’ surrounding str. If str is not enclosed by angle brackets or these are unbalanced, the argument is returned unchanged:
dequote("<root@gnu.org.ua>") ⇒ "root@gnu.org.ua" dequote("root@gnu.org.ua") ⇒ "root@gnu.org.ua" dequote("there>") ⇒ "there>"
Returns the local part of str if it is a valid email address, otherwise returns str unchanged.
localpart("gray") ⇒ "gray" localpart("gray@gnu.org.ua") ⇒ "gray"
Replicate a string, i.e. return a string, consisting of s repeated n times:
replstr("12", 3) ⇒ "121212"
Returns the string composed of the characters from s in reversed order:
revstr("foobar") ⇒ "raboof"
Returns the index of the last occurrence of the string t in the string s, or -1 if t is not present.
rindex("string of rings", "ring") ⇒ 10
Optional argument start, if supplied, indicates the position in string where to start searching. E.g.:
rindex("string of rings", "ring", 10) ⇒ 2
See also String manipulation.
Returns the at most length-character substring of str starting at start. If length is omitted, the rest of str is used.
If length is greater than the actual length of the string, the
e_range
exception is signalled.
substr("mailfrom", 4) ⇒ "from" substr("mailfrom", 4, 2) ⇒ "fr"
Returns a substring of str between offsets start and
end, inclusive. Negative end means offset from the end of
the string. In other words, yo obtain a substring from start to the
end of the string, use substring(str, start, -1)
:
substring("mailfrom", 0, 3) ⇒ "mail" substring("mailfrom", 2, 5) ⇒ "ilfr" substring("mailfrom", 4, -1) ⇒ "from" substring("mailfrom", 4, length("mailfrom") - 1) ⇒ "from" substring("mailfrom", 4, -2) ⇒ "fro"
This function signals e_range
exception if either start or
end are outside the string length.
Returns a copy of the string str, with all the upper-case characters translated to their corresponding lower-case counterparts. Non-alphabetic characters are left unchanged.
tolower("MAIL") ⇒ "mail"
Returns a copy of the string str, with all the lower-case characters translated to their corresponding upper-case counterparts. Non-alphabetic characters are left unchanged.
toupper("mail") ⇒ "MAIL"
Returns a copy of the input string str with any leading characters present in cset removed. If the latter is not given, white space is removed (spaces, tabs, newlines, carriage returns, and line feeds).
ltrim(" a string") ⇒ "a string" ltrim("089", "0") ⇒ "89"
Note the last example. It shows how ltrim
can be used to
convert decimal numbers in string representation that begins with
‘0’. Normally such strings will be treated as representing octal
numbers. If they are indeed decimal, use ltrim
to strip off
the leading zeros, e.g.:
set dayofyear ltrim(strftime('%j', time()), "0")
Returns a copy of the input string str with any trailing characters present in cset removed. If the latter is not given, white space is removed (spaces, tabs, newlines, carriage returns, and line feeds).
Compares two strings as mailfromd
version numbers. The
result is negative if b precedes a, zero if they refer to
the same version, and positive if b follows a:
vercmp("5.0", "5.1") ⇒ 1 vercmp("4.4", "4.3") ⇒ -1 vercmp("4.3.1", "4.3") ⇒ -1 vercmp("8.0", "8.0") ⇒ 0
Format code as a floating-point number with prec decimal digits:
sa_format_score(5000, 3) ⇒ "5.000"
This function is convenient for formatting SpamAssassin scores for use in message headers and textual reports. It is defined in module sa.mfl.
See SpamAssassin, for examples of its use.
Format a SpamAssassin report text in order to include it in a RFC 822 header. This function selects the score listing from text, and prefixes each line with ‘* ’. Its result looks like:
* 0.2 NO_REAL_NAME From: does not include a real name * 0.1 HTML_MESSAGE BODY: HTML included in message
See SpamAssassin, for examples of its use.
Returns at most n last components of the domain name domain. If n is 0 the function returns domain.
This function is defined in the module strip_domain_part.mfl (see Modules).
Examples:
require strip_domain_part strip_domain_part("puszcza.gnu.org.ua", 2) ⇒ "org.ua" strip_domain_part("puszcza.gnu.org.ua", 0) ⇒ "puszcza.gnu.org.ua"
If email is a valid VERP-style email address for domain, that corresponds to a valid local user name (see validuser), this function returns the local user name, corresponding to that email. Otherwise, it returns empty string.
For example, assuming the local user ‘gray’ exists:
verp_extract_user("gray=gnu.org.ua@tuhs.org", 'gnu\..*') ⇒ "gray"
Next: String formatting, Previous: String transformation, Up: Library [Contents][Index]