For example, the regular expression "abc+" has no sub-expressions while the regular expression "(a)(b)(c+)" has 3 subexpressions. A subexpression is any part of a regular expression written within parentheses. Setting SUBEXPR causes it to return an array containing the overall match as well as any subexpression matches. SUBEXPRīy default, IDL_STRING::Extract only returns a single string containing the overall match (or a string array if your variable was an array). Set this keyword to ignore case when doing comparisons. The regular expression to match against var. If var is an array then Result is a string array of the same dimensions. Result = var.Extract( String ) Return ValueĪ string containing the extracted text. ExamplesĬreate a sentence and extract text out of it: str = "Hello fellow IDL user." PRINT, str. The IDL_String::Extract method extracts the first substring that matches a regular expression. The string to compare against the end of the string variable. If var is an array then Result is a byte array of the same dimensions. Result = var.EndsWith( String ) Return ValueĪ boolean value of 0 (false) or 1 (true). ExamplesĬreate a sentence and print the result of EndsWith on that sentence: str = "hello fellow IDL user." Check if the string ends with 3 periods. The IDL_String::EndsWith method determines whether the string ends with a given string. The result is a boolean value 1 (true) if the string contains the substring, or 0 otherwise. Result = var.Contains( Substring, /FOLD_CASE ) Return Value Examplesĭetermine whether each element of a string array contains a specific substring: str = PRINT, str. The IDL_String::Contains method determines whether the string contains a given substring. If var is an array then the result is a string array of the same dimensions. Compress() Print the new string and its length. ExamplesĬreate a string with spaces: str = " I D L is C o o l ! " PRINT, str. This is equivalent to calling STRCOMPRESS with the REMOVE_ALL keyword. The IDL_String::Compress method removes all spaces and tabs within a string.
Result = var.CharAt( Index ) Return ValueĪ string containing the character found at the given index. ExamplesĬreate a string and print the result given an index: str = "IDL" Print the character at each index. The IDL_String::CharAt method returns a character from the string.
Set this keyword to ignore the capitalization of the first character. Set this keyword to ignore case when searching for space characters. ArgumentsĪ character string designating the space character that will capitalize each character immediately following the space character. Result = var.CapWords( ) Return ValueĪ string with a value containing capitalized characters as specified by the given argument or keywords. CapWords( '_', /FOLD_CASE, /IGNORE_FIRST) Pass in a character for the space argument, and include the optional keywords: str = "hello_fellow_IDL_user." PRINT, str. ExamplesĬreate a sentence and print the result of CapWords on that sentence: str = "hello fellow IDL user." PRINT, str. The IDL_String::CapWords method capitalizes the beginning letter of all words within the string. Trim: Removes leading and trailing white space.ToUpper: Convert all characters to uppercase.ToLower: Convert all characters to lowercase.StartsWith: Returns true if the string starts with the given string.Split: Split into substrings using a regular expression.Replace: Replaces text within the string.Matches: Returns true if the string matches a regular expression.LastIndexOf: Returns the last index of a character or substring.Join: Combines multiple strings into a single string.
IndexOf: Returns the index of a character or substring.Extract: Returns part of the string using a regular expression.EndsWith: Returns true if the string ends with the given string.Contains: Returns true if the string contains a given substring.CharAt: Returns the character at the supplied index.CapWords: Capitalize any words contained within the string.In addition, because IDL_String is a subclass of IDL_Variable, all of the IDL_Variable methods are also available. The IDL_String class contains static methods that are available for all IDL strings.