Table of String Functions

The NLP++ functions used to operate on strings are listed here in table form for easy reference.  For examples of these functions, refer to the individual function pages included in the String Functions section.  

The return types include:  STR (string), STR ARRAY (string array), INT (integer), and BOOL (Boolean).  Boolean type is currently implemented by integer 1 (or non-zero) for true and 0 for false.

FUNCTION NAME

RETURNS

DESCRIPTION

deaccent(str)

STR

Convert string to replace accented characters.

dejunk(str)

STR

Convert string to replace all but simple ASCII chars. New in 2.6.0.3.

flt(str)

FLOAT

Convert string or int to float, if possible.

levenshtein(str1,str2)

INT

Levenshtein edit-distance between two strings. New in 2.0.2.9

num(str)

INT

Convert string to number, if possible. (Also accepts num arg).

split(str, char_str)

STR ARRAY

Split a string using the given char as separator.

stem(str)

STR

Compute stem of noun and verb. Return lowercase string.

strchar(str, num)

STR

Index to numth char of string

strchr(str, ch_str)

STR

Find first occurrence of char in string. Return string headed by char.

strchrcount(str, ch_str)

INT

Count the occurrences of a character in a string.

strclean(str)

STR

Remove leading, trailing, and repeat whitespace separators.

strcontains(str1,str2)

BOOL

Check if str1is contained in str2.

strcontainsnocase(str1,str2)

BOOL

Check if str1 is contained in str2, ignoring letter case.

strendswith(str, suffix_str)

BOOL

Does given str ends with given suffix_str

strstartswith(str, suffix_str)

BOOL

Does given str starts with given suffix_str

strequal(str1,str2)

BOOL

Check if str1 is identical to str2.

strisalpha(str)

BOOL

Check if str is all alphabetic chars.

strisdigit(str)

BOOL

Check if str is all numeric chars.

strislower

BOOL

Check if first char of string is lowercase

strisupper

BOOL

Check if first char of string is uppercase.

striscaps

BOOL

Check if the entire string is uppercase.

strnotequal(str1,str2)

BOOL

Check if str1 differs from str2.

strequalnocase(str1,str2)

BOOL

Check if str1 is identical to str2, ignoring letter case.

strnotequalnocase(str1,str2)

BOOL

Check if str1 differs from str2, ignoring letter case.

strlessthan(str1,str2)

BOOL

Check if str1 is lexically before str2.

strgreaterthan(str1,str2)

BOOL

Check if str1 is lexically after str2.

strlength(str)

INT

Return length of string.

strpiece(str, start_num, end_num)

STR

Fetch substring of string from start_num to end_num indexes. Zero-based

struniquechars(str)

STR

Find all the unique characters in a string.

strrchr(str, ch_str)

STR

Find last occurrence of char in string. Return string headed by char

strsubst(str, old_str, new_str)

STR

Replace substring old_str of a string str with new_str.

strtolower(str)

STR

Convert string to lowercase.

strtotitle(str)

STR

Convert string to title capitalization.

strtoupper(str)

STR

Convert string to uppercase.

strtrim(str)

STR

Remove leading and trailing whitespace from str.

strwrap(str, num)

STR

Break string at specified length.

str(num)

STR

Convert numeric value to string. (Also accepts string arg).

strescape(str, charsToEscapeStr, escapeStr)

STR

Escape characters in string.

strunescape(str, escapedCharsStr, escapeStr)

STR

Unescape characters in string.

suffix(wordStr, suffixStr)

BOOL

True if suffixStr may be the suffix of wordStr.

unpackdirs(dir_str)

STR ARRAY

Unpack directory names from a full directory path string.

xmlstr(str)

STR

Convert chars to appropriate chars for an XML/HTML file.

 

 

 

See Also

Special Functions

Knowledge Base Functions

Formatting and I/O Functions

Parse Tree Functions

Spelling Functions