Work with Character Functions in the Scripting Guide provides more details about some of the functions.
Optional quoted string that specifies an encoding. The default encoding for the character string is utf-8. utf-16le, utf-16be, us-ascii, iso-8859-1, ascii-hex, shift-jis, and euc-jp are also supported.
The optional argument ascii is intended to make conversions of blobs containing normal ASCII data simpler when the data might contain CR, LF, or TAB characters (for example) and those characters do not need any special attention.
Creates a matrix by converting each byte in the blob to numbers.
–
|
"big" indicates that the first byte is the most significant.
|
–
|
"little" indicates that the first byte is the least significant.
|
–
|
"native" indicates that the machine’s native format should be used.
|
an expression or a numeric value. An expression must be quoted with Expr(). Otherwise, its evaluated value is converted to a string.
Char( Pi(), 10, 4)
"3.1416"
Char( Pi(), 3, 4)
"3.1"
Optional quoted string that specifies an encoding. The default encoding for the blob is utf-8. utf-16le, utf-16be, us-ascii, iso-8859-1, ascii-hex, shift-jis, and euc-jp are also supported.
Converting BLOBS into printable format escapes \ (in addition to ~ " ! and characters outside of the printable ASCII range) into hex notation (~5C for the backslash character).
x = Char To Blob( "abc\def\!n" );
y = Blob To Char( x, encoding = "ASCII~HEX" );
If(
y == "abc~5Cdef~0A", "JMP 12.2 and later behavior",
y == "abc\def~0A", "Pre-JMP 12.2 behavior"
);
"JMP 12.2 and later behavior" // output
Optional quoted string that specifies an encoding. The default encoding is utf-8. utf-16le, utf-16be, us-ascii, iso-8859-1, ascii-hex, shift-jis, and euc-jp are also supported.
Trims leading and trailing whitespace and replaces interior whitespace with a single space. That is, if more than one white space character is present, the Collapse Whitespace function replaces the two spaces with one space.
a = "Hello"; b = " "; c = "World"; a || b || c;
"Hello World"
d = {"apples", "bananas"}; e = {"peaches", "pears"}; Concat( d, e );
{"apples", "bananas", "peaches", "pears"}
A = [1 2 3]; B = [4 5 6]; Concat( A, B );
[1 2 3 4 5 6]
a = "Hello"; b = " "; c = "World"; Concat To( a, b, c ); Show( a );
a = "Hello World"
A = [1 2 3]; B = [4 5 6]; Concat To( A, B ); Show( A );
A = [1 2 3 4 5 6];
If part is found: For lists, strings, and namespaces, the numeric position where the first occurrence of part is located. For associative arrays, 1.
If part is not found, 0 is returned in all cases.
For a string or namespace, a string that can be part of the string whole. For a list, an item that can be an item in the list whole. For an associative array, a key that can be one of the keys in the map whole.
An optional numeric argument that specifies a starting point. within whole. If start is negative, contains searches whole for part backwards, beginning with the position specified by the length of whole – start. Note that start is meaningless for associative arrays and is ignored.
nameList={"Katie", "Louise", "Jane", "Jaclyn"};
r = Contains(nameList, "Katie");
Returns a Boolean that indicates whether the word (item), one of a list of words (list), or pattern (pattern) matches one of the words in the text represented by x. Words are delimited by the characters in the optional delimiter (delimiter) string. A comma, ",", character is the default delimiter. Blanks are trimmed from the ends of each extracted word from the input text string (x).
The following example searches for “pots” followed by a comma and then outputs the result.
x = "Franklin Garden Supply is a leading online store featuring garden decor, statues, pots, shovels, benches, and much more.";
b = Contains Item( x, "pots", "," );
If( b,
Write( "The specified items were found." ), "No match."
);
The specified items were found.
Right(string, Length(substring)) == substring
Converts the quoted hexadecimal string (including whitespace characters) to a blob (binary large object).
Hex To Blob( "4A4D50" );
Char To Blob("JMP", "ascii~hex")
Converts the quoted hexadecimal string to its character equivalent.
The default encoding for character string is utf-8. utf-16le, utf-16be, us-ascii, iso-8859-1, ascii-hex, shift-jis, and euc-jp are also supported.
Converts the quoted hexadecimal string to its integer or its floating number equivalent.
Hex To Number( "80" );
128
Whitespace between bytes (or pairs of digits) and in the middle of bytes is permitted (for example, FF 1919 and F F1919).
Extracts the nth word from a quoted string according to the quoted string delimiters given. The default delimiter is space. If you include a third argument, any and all characters in that argument are taken to be delimiters.
Item() is the same as Word() except that Item() treats each delimiter character as a separate delimiter, and Word() treats several adjacent delimiters as a single delimiter.
Item( 4,"the quick, brown fox", ", " );
"brown"
Word( 4,"the quick, brown fox", ", " );
"fox"
Returns a truncated or padded version of the original string or list. The result contains the left n characters or list items, padded with any filler on the right if the length of string is less than n.
Converts any upper case character found in quoted string to the equivalent lowercase character.
Computes new character strings from the quoted string by inserting or deleting characters. It can also produce substrings, calculate indexes, and perform other tasks depending on how you specify its arguments.
Offset is a numeric expression indicating the starting position to search in the string. If the offset is greater than the position of the first instance of the find argument, the first instance is disregarded. If the offset is greater than the search string’s length, Munger uses the string’s length as the offset.
Optional. A backreference to the capturing group. The default is /0, which is the entire matched string. /n returns the nth match.
Returns a copy of source concatenated with itself a times. Or returns a matrix composed of a row repeats and b column repeats. The source can be text, a matrix, or a list.
Returns a truncated or padded version of the original string or list. The result contains the right n characters or list items, padded with any filler on the left if the length of string is less than n.
Left(string, Length(substring)) = = substring
Substr( "Katie Layman", 1, 5 );
Titlecase( "veronica layman ")
"Veronica Layman"
Trim( " John ", both )
"John"
Converts any lower case character found in the quoted string to the equivalent uppercase character.
Extracts the nth word from a character string according to the delimiters given. The default delimiter is space. If you include a third argument, any and all characters in that argument are taken to be delimiters.
Word( 2, "Katie Layman" );
Word() is the same as Item(), except that Item() treats each delimiter character as a separate delimiter, and Word() treats several adjacent delimiters as a single delimiter.
Item( 4,"the quick brown fox" );
"brown"
Word( 4,"the quick brown fox" );
"fox"
The following example stores the XML document in a variable. The XPath Query expression parses the XML to find the text nodes inside the <result> tags. The results are returned in a list.
rpt =
"\[<?xml version="1.0" encoding="utf-8"?>
<JMP><report><title>Production Report</title>
<result>November 21st: Pass</result>
<result>November 22nd: Fail</result>
<note>Tests ran at 3:00 a.m.</note></report>
</JMP> ]\";
results = XPath Query( rpt, "//result/text()" );
{"November 21st: Pass", "November 22nd: Fail"}