YOUSEFUL / FILEMAKER
YsflText functions (v1.0.0)
All text is UTF-8. Value lists use ¶ (\r); \n and \r\n are accepted on
input. A failing call returns ? message and sets YsflTx_LastError / YsflTx_LastErrorText.
Options are space-separated tokens.
Plugin
| Function | Returns |
|---|---|
YsflTx_Version |
YsflText v.1.0.0 |
YsflTx_Register ( {option} ) |
Registered. |
YsflTx_LastError |
numeric code of the last failure in this plugin (0 = none) |
YsflTx_LastErrorText |
message of the last failure |
Error codes: 1001 parameter, 1002 option, 1003 regex, 1004 encoding, 1005 XML, 1006 out of memory, 1007 crypto.
Regex (Perl-compatible, PCRE2, Unicode)
Options: i caseless, m multiline, s dot matches newline, x extended, u ungreedy, 1 first match only (Replace).
| Function | Description |
|---|---|
YsflTx_RegexMatch ( text ; pattern ; {options} ) |
1 if the pattern matches anywhere, else 0 |
YsflTx_RegexFind ( text ; pattern ; {options} ; {group} ) |
first match; group = number or name of a capture |
YsflTx_RegexFindAll ( text ; pattern ; {options} ; {group} ) |
every match, one per line |
YsflTx_RegexReplace ( text ; pattern ; replacement ; {options} ) |
replace all (or first with 1); $1, ${name}, $$ |
YsflTx_RegexSplit ( text ; pattern ; {options} ) |
pieces between matches, one per line |
YsflTx_RegexCount ( text ; pattern ; {options} ) |
number of matches |
YsflTx_RegexGroups ( text ; pattern ; {options} ) |
capture groups of the first match, one per line |
YsflTx_RegexEscape ( text ) |
text with metacharacters escaped |
Lines and words
Option i compares case-insensitively (original lines are returned).
| Function | Description |
|---|---|
YsflTx_LinesAnd ( text1 ; text2 ; {options} ) |
lines in both |
YsflTx_LinesOr ( text1 ; text2 ; {options} ) |
union, first appearance order |
YsflTx_LinesXor ( text1 ; text2 ; {options} ) |
lines in exactly one |
YsflTx_LinesNot ( text1 ; text2 ; {options} ) |
lines of text1 not in text2 |
YsflTx_LinesUnique ( text ; {options} ) |
first occurrence of each line |
YsflTx_LinesSort ( text ; {options} ) |
desc, i, num (natural numeric), unique |
YsflTx_LinesReverse ( text ) |
reversed |
YsflTx_LinesTrim ( text ; {options} ) |
trim each line; empty drops empty lines |
YsflTx_LineGet ( text ; index ; {count} ) |
line(s) from a 1-based index; negative counts from the end |
YsflTx_LineCount ( text ) |
number of lines |
YsflTx_WordsUnique ( text ; {options} ) |
unique words in order of appearance |
YsflTx_WordCount ( text ) |
number of words |
Hashing and encoding
Algorithms: sha256 (default), sha1, sha512, md5, crc32, fnv1a. Encodings: hex (default), HEX, base32, base64, safe (unambiguous alphabet, hyphenated every 4 characters).
| Function | Description |
|---|---|
YsflTx_Hash ( text ; {algorithm} ; {encoding} ) |
digest of the UTF-8 bytes |
YsflTx_HashCompare ( text ; hash ; {algorithm} ; {encoding} ) |
1 when the digest equals hash (constant time) |
YsflTx_Base64Encode ( text ) |
Base64 |
YsflTx_Base64Decode ( text ) |
decoded text |
YsflTx_UrlEncode ( text ; {options} ) |
percent-encoding; form uses + for spaces |
YsflTx_UrlDecode ( text ) |
decoded |
YsflTx_HtmlEncode ( text ) |
& < > " ' escaped |
YsflTx_HtmlToText ( html ) |
tags removed, block ends become returns, entities decoded |
Transforms
| Function | Description |
|---|---|
YsflTx_Case ( text ; mode ) |
upper, lower, title, sentence, toggle |
YsflTx_Trim ( text ; {chars} ) |
strip whitespace or the given characters from both ends |
YsflTx_Collapse ( text ) |
whitespace runs become one space, trimmed |
YsflTx_IsEmail ( text ) |
1 for a plausible address |
YsflTx_FormatPhone ( digits ; {pattern} ) |
digits placed into # slots, default (###) ###-####; extras appended |
YsflTx_Pad ( text ; width ; {char} ; {side} ) |
pad to width; side left (default), right, center |
YsflTx_Repeat ( text ; count ) |
text repeated |
YsflTx_CsvToLines ( csvRow ; {separator} ) |
fields one per line, quotes honored |
YsflTx_LinesToCsv ( lines ; {separator} ) |
quoted where needed |
XML
Paths are root/child[2]/leaf with 1-based indexes.
| Function | Description |
|---|---|
YsflTx_XmlNode ( xml ; path ) |
decoded text, or raw inner markup when the node has element children |
YsflTx_XmlAttributes ( xml ; path ; {name} ) |
name="value" lines, or one attribute's value |
YsflTx_XmlCount ( xml ; path ) |
number of matching nodes at the last step |