info.mailtraq.com > Management > Script Functions A-Z > SubStr() SubStr()Returns a substring taken from the given string. The position and length of the required substring are given as parameters.
sub := SubStr( string , index , length )
- sub
- The resulting substring
- string
- The string from which a substring is to be extracted
- index
- The index offset, commencing at one, of the first character to extract from the string
- length
- The number of characters to extract
// Extract "some" from "This is some text"
"some" := Substr("This is some text", 9, 4)
// Rewrite References header to ensure whitespace between all msg-id
ref_list := Header("References");
If(WildcardMatch(ref_list, "*><*"),
Do(
rev_list := "",
i := 1,
While(i <= Length(ref_list),
Do(
rev_list := If(Length(rev_list) > 0, rev_list) ++
SubStr(ref_list, i, 1) ++
If(SubStr(ref_list, i, 1) = ">", " "),
i := i + 1
)
),
SetHeader("References", rev_list)
)
) |